Support » Plugin: Display Featured Image for Genesis » How to disable "Display Featured Image Genesis" for post or category

  • Resolved steckinsights

    (@steckinsights)


    Hi Robin,

    This is a beautiful plugin and I appreciate your responsiveness on the forums! Had a question that I haven’t been able to solve yet:

    If I’d like to disable the plugin on particular posts, pages, categories or post types, is there a particular action I can remove that would accomplish this?

    I’ve been scouring the code and can’t seem to find the right hook and function to pull the Display Featured Image Genesis plugin off a particular post or page.

    I’m familiar enough with Genesis and WordPress to write code that would remove an action from a particular page… I’m just not sure which action you’ve established that would allow me to remove it.

    Example:

    function custom_disable_featured_image_plugin() {
    if (is_page('example')) {
    remove_action('desired_genesis_header','desired_plugin_action');
    }
    }
    add_action('genesis_header','custom_disable_featured_image_plugin');

    What would the “desired_genesis_header” and “desired_plugin_action” be? Is this possible with your plugin?

    https://wordpress.org/plugins/display-featured-image-genesis/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Robin Cornett

    (@littlerchicken)

    Yes, it’s very possible. There are actually two different filters you could use to accomplish this–either should work, so it’s just up to you which you would want to do.

    There is a skipped post types filter, which also works with a lot of different conditional statements:

    add_filter( 'display_featured_image_genesis_skipped_posttypes', 'rgc_skip_post_types' );
    function rgc_skip_post_types( $post_types ) {
    	$post_types[] = is_single( 1370 ); // the number is the ID of the specific post/page
    
    	return $post_types;
    }

    The other option would be to just tell the plugin not to assign an image for its use on that particular page:

    add_filter( 'display_featured_image_genesis_image_id', 'rgc_do_not_show_on_this' );
    function rgc_do_not_show_on_this( $image_id ) {
    	if ( is_single( 1370 ) ) { // the number is the ID of the specific post/page
    		return;
    	}
    	return $image_id;
    
    }

    As long as your is_page( 'example' ) is a valid conditional, it should work. In my case, I was just testing it on a specific post type by ID, but any conditional should work as well, especially with the second one, as the plugin handles it slightly differently. If the plugin has no featured image ID, it will not load any of its assets or do any of its work.

    Hope that helps!

    Robin

    Thread Starter steckinsights

    (@steckinsights)

    Robin,

    Thanks for your help! I figured that there was a way to do it, but couldn’t find the function or the argument that would allow for it. Thank you for staying to active on the forums!

    Can you tell me how to disable Featured Image for ALL category pages? I don’t know how to write code, so a simple explanation would be appreciated. I want the featured image to show up on posts, but not, for example, on this category page: http://www.globaltwincities.com/category/ethiopian/.
    Thanks,
    Jeremy

    Plugin Author Robin Cornett

    (@littlerchicken)

    You’ll want to use the same skipped post types filter, but with a different conditional tag. For example, this:

    add_filter( 'display_featured_image_genesis_skipped_posttypes', 'prefix_skip_category' );
    function prefix_skip_category( $post_types ) {
    	$post_types[] = is_category();
    	return $post_types;
    }

    will prevent the featured image from loading on any category archive page. If you want to target only specific categories, you need to modify that conditional according to the Codex. HTH

    Balou

    (@harryluiten)

    Thank you Robin for the plugin but specially for the prevent loading on category and archive pages code. I was busy for hours and close untill I found your solution. Next time it is better to Google first then to invent the wheel myself.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to disable "Display Featured Image Genesis" for post or category’ is closed to new replies.