Skip to content

Instantly share code, notes, and snippets.

@GaryJones
Created February 15, 2012 21:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save GaryJones/1839234 to your computer and use it in GitHub Desktop.
Save GaryJones/1839234 to your computer and use it in GitHub Desktop.
Remove featured image on blog page posts that are in a specific category.
<?php
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 http://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 ( ! has_category( 126, $post ) )
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' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment