Hide the featured image of a specific category
-
Hi.
I want to hide the featured image of a specific category on a blog page in Genesis. I have used this code from Travis Smith, but it stopped working once my Eleven40 StudioPress theme was converted to HTML5:
add_action( 'genesis_before_post' , 'wps_no_featured_image' ); add_action( 'genesis_after_post_content' , 'wps_no_featured_image' ); /* * Remove featured image from certain posts. * * Stops featured image from displayed on the Small Group Show category (126) on * the blog page. * * @author Travis Smith * @link https://wpsmith.net/2012/genesis/how-to-hide-the-featured-image-of-a-specific-category-on-the-blog-page-in-genesis/ * * @global stdClass $post Post object. * * @return null Returns early if post is not in our chosen category. */ function wps_no_featured_image() { global $post; if (! in_category( array( 20,21,22 ) ) ) return; if ( 'genesis_before_post' == current_filter() ) remove_action( 'genesis_post_content', 'genesis_do_post_image' ); elseif ( 'genesis_after_post_content' == current_filter() ) add_action( 'genesis_before_post_content', 'genesis_do_post_image' ); }
You will note I’m trying to hide the featured images of categories 20,21 and 22:
if (! in_category( array( 20,21,22 ) ) )
Yes, I did change the old XHTML loop hooks to the new HTML5 hooks:
add_action( 'genesis_before_entry' , 'wps_no_featured_image' ); add_action( 'genesis_entry_footer' , 'wps_no_featured_image' ); function wps_no_featured_image() { global $post; if (! in_category( array( 20,21,22 ) ) ) return; if ( 'genesis_before_entry' == current_filter() ) remove_action( 'genesis_entry_content', 'genesis_do_post_image' ); elseif ( 'genesis_entry_footer' == current_filter() ) add_action( 'genesis_before_entry_content', 'genesis_do_post_image' ); }
but it still does not work.
I’m front-end so this is completely baffling me.
I can’t find a plugin that does it (I’d rather not if I can help it).
I have tried the StudioPress forums.
Looking for a genius here…! Any help would be much appreciated.
??
- The topic ‘Hide the featured image of a specific category’ is closed to new replies.