Hello Nischal,
Yes it’s possible.
As noted in the FAQ
Create a file named wp-content/plugins/dif-no-page-post.php
Put the following code inside, and activate the plugin in the dashboard
<?php
/**
* Plugin Name: Default Featured Image, apply to posts only.
* Plugin URI: https://wordpress.org/support/topic/create-default-featured-image-for-one-custom-post-type-only/
* Version: 1.0
*/
function dfi_no_page_post( $dfi_id, $post_id ) {
$post = get_post( $post_id );
if ( in_array($post->post_type, array( 'post', 'page',)) ) {
return 0; // Don't use DFI for this post or pages
}
return $dfi_id; // the original featured image id
}0
add_filter( 'dfi_thumbnail_id', 'dfi_no_page_post', 10, 2 );
This should exclude normal posts and pages, to include more posttypes add them in the array in_array($post->post_type, array( 'post', 'page', 'EXTRA',)
Let me know how it goes.
Jan-Willem
Hi Jan,
thank you for the quick response and thanks for providing the code as well. So from the code, what I understood it the plugin works for all and we just need to put exclusions only. Is that correct? It will exclude post, page and any extra cpt etc.
Hello Nischal,
Yes the code is structured that is will exclude certain posttypes, these will not use the DFI.
In my example posts and pages are excluded.
Let me know
Jan-Willem