• Hello,

    Thanks for the plugin, it works great!

    I am using Default Featured Image (DFI) as well as Modern Events Calendar (MEC) on my site. Once activated, DFI works as expected. The fallback featured image is show on all posts without a specified image, even events created within MEC.

    However, I wish to exclude MEC posts from DFI’s influence as it has it’s own fallback image mechanics for event categories. Using dfi_thumbnail_id filter like this…

    
    function dfi_no_page_post( $dfi_id, $post_id ) {
    	$post = get_post( $post_id );
    	if ( in_array($post->post_type, array( 'mec-events',)) ) {
    		return 0; // Don't use DFI for this post or pages
    	}
    
    	return $dfi_id; // the original featured image id
    }
    
    add_filter( 'dfi_thumbnail_id', 'dfi_no_page_post', 10, 2  );

    …doesn’t work. The default image set in DFI settings is still shown. If I use the same filter for one of my own custom post types (say ‘formations’), it works fine, not using the fallback image on ‘formations’ type posts.

    Any ideas?

    Thank you!

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

    (@janwoostendorp)

    Hello Maxbel,

    That is weird to hear.
    There are 2 things that come to mind.
    Either the filter is not called or the plugin uses a different posttype then you are testing against.

    I suggest adding a var_dump, and check if that shows and what it shows:

    function dfi_no_page_post( $dfi_id, $post_id ) {
    	$post = get_post( $post_id );
    	var_dump( $post );
    	if ( in_array($post->post_type, array( 'mec-events',)) ) {
    		return 0; // Don't use DFI for this post or pages
    	}
    
    	return $dfi_id; // the original featured image id
    }
    
    add_filter( 'dfi_thumbnail_id', 'dfi_no_page_post', 10, 2  );

    Let me know how it goes.
    Jan-Willem

    Thread Starter maxbel0117

    (@maxbel0117)

    Hi! Thanks for the fast reply!

    In the var_dump, the post type is showing up as “mec-events”, here’s part of the dump:

    (...)["post_type"]=> string(10) "mec-events" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" } object(WP_Post)#20950(...)

    I don’t quite see why the filter wouldn’t be called when the rest of the plugin’s functionality is intact (it is showing the default fallback image)… and it would only not be called in regards to the mec-events post type?

    How would I go about checking for that?

    • This reply was modified 3 years, 3 months ago by maxbel0117.
    • This reply was modified 3 years, 3 months ago by maxbel0117.
    Plugin Author Jan-Willem

    (@janwoostendorp)

    Hi Maxbel,

    the plot thikens….
    I didn’t expect this.
    you can put the vardump inside the if, and see if the if is triggered.

    I’m a bit baffled.
    Inside the if, you did put an media ID that is different that isn’t the same as the DFI?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Cannot exclude MEC post type from showing default image’ is closed to new replies.