• Resolved Dave Loebig

    (@pacesettermedia)


    This is a solution I’m sharing since I couldn’t find a direct answer.

    GOAL: Restrict the default image to a single post type

    I modified code from janw.oostendorp, and it works. I’m adding it for future searchers.

    function dfi_custom_posttypes( $dfi_id, $post_id ) {
    	$post = get_post( $post_id );
    
    	// remove null featured image ID for all post types except "post"
    	if ( $post->post_type !== 'post' ) {
    	    return null; // return no image selection.
    	}
    
    	return $dfi_id; // the original featured image id
    }
    
    add_filter( 'dfi_thumbnail_id', 'dfi_custom_posttypes', 10, 2 );
    

    I’m not an advanced programmer, so if there’s a better way, please let me know.

    Thanks for the great plugin.

Viewing 1 replies (of 1 total)
  • Plugin Author Jan-Willem

    (@janwoostendorp)

    Hi Dave.

    Always good to hear someone tweaking it by themselves.

    This is exactly how I would code this.

    Best, Jan-Willem

Viewing 1 replies (of 1 total)

The topic ‘Restrict Default Image to One Post Type’ is closed to new replies.