Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author janw.oostendorp

    (@janwoostendorp)

    In the FAQ I describe how to do that. Here is an example for the wiki posttype. Replace with your own posttype and put it in your theme’s functions.php

    function dfi_posttype_wiki ( $dfi_id, $post_id ) {
      $post = get_post($post_id);
      if ( 'wiki' === $post->post_type ) {
        return $dfi_id; // the image set in the media settings
      }
      return 0; // don't show the default featured image on other posttyes
    }
    add_filter( 'dfi_thumbnail_id', 'dfi_posttype_wiki', 10, 2 );

    Let me know how it went.

    Thread Starter developerlopez

    (@developerlopez)

    I am so sorry. I don’t see the FAQ but thank you very much. Your code works fine.

    Thank you. Regards.

    Thanks for this! I was looking for a way to have the default image not used on the post types created by the time.ly calendar plugin- a mod of the code above works to use DFI only on posts:

    function dfi_posttype_that ( $dfi_id, $post_id ) {
      $post = get_post($post_id);
      if ( 'post' === $post->post_type ) {
        return $dfi_id; // the image set in the media settings
      }
      return 0; // don't show the default featured image on other posttyes
    }
    
    add_filter( 'dfi_thumbnail_id', 'dfi_posttype_that', 10, 2 );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Featured image for one category’ is closed to new replies.