Support » Plugin: Default featured image » Image depends on tag

  • Resolved nitzanginsberg

    (@nitzanginsberg)


    Hello
    Is there any chance the plugin can support defult image by tag and not by category ? or any future update in this case ?

    Thanks

    Nitzan

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

    (@janwoostendorp)

    Hi nitzanginsberg,

    The plugin does not support tags and categories in the interface.
    But you can tweak your own:

    function dfi_tag( $dfi_id, $post_id ) {
    	// all which have 'animals' as a category.
    	if ( has_tag( array( 'cats', 'dogs' ), $post_id ) ) {
    		return 8; // image ID for cats or dogs .
    	} elseif ( has_tag( 'chicken', $post_id ) ) {
    		return 9; // image ID for cats or dogs .
    	}
    
    	return $dfi_id; // the original featured image id
    }
    add_filter( 'dfi_thumbnail_id', 'dfi_tag', 10, 2 );

    If you insert this in your theme’s functions.php (or in a separate mu-plugin). it will set a different image for cats and dogs. And another different image for chickens.

    Let me know how it goes.
    Jan Willem

Viewing 1 replies (of 1 total)
  • The topic ‘Image depends on tag’ is closed to new replies.