• Resolved jamescl

    (@jamescl)


    Hi,

    Is there a way to limit to to certain post types?

    Specifically for me, this plugin is generating images in for forum posts, which don’t use featured images generally, and creating un-necessary images in the image library.

    I really only need this for posts only and not pages/forums/topics/replies etc, so would be good to limit to posts only

    • This topic was modified 5 years, 8 months ago by jamescl.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Michael Beckwith

    (@tw2113)

    The BenchPresser

    Closest way I can see to prevent this from running would be with this filter:

    $content = apply_filters( 'wds_featured_images_from_video_filter_content', $content, $post_id );
    

    Something like this would theoretically work:

    function jamescl_afi_posts_only( $content, $post_id ) {
        if ( 'post' !== get_post_type( $post_id ) {
            return '';
        }
        return $content.
    }
    add_filter( 'wds_featured_images_from_video_filter_content', 'jamescl_afi_posts_only', 10, 2 );
    

    Basically if the post type is not “post”, then return an empty string which will basically “short circuit” the finding of data and not process further. Otherwise, return the original content passed in which would potentially have video urls.

    Thread Starter jamescl

    (@jamescl)

    Hi,

    Thanks for your help. I got it working by using

    function jamescl_afi_posts_only( $content, $post_id ) {
    if ( 'post' !== get_post_type( $post_id ) ){
    return '';
    }
    return $content;
    }
    add_filter( 'wds_featured_images_from_video_filter_content', 'jamescl_afi_posts_only', 10, 2 );

    Plugin Support Michael Beckwith

    (@tw2113)

    The BenchPresser

    Awesome. Let us know if you have any other questions.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Restrict to certain post types (e.g. don’t do it for forumns)’ is closed to new replies.