• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Exclude Single Post Featured Image From Certain Categories

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Exclude Single Post Featured Image From Certain Categories

This topic is: not resolved

Tagged: feature image, single post

  • This topic has 3 replies, 3 voices, and was last updated 11 years ago by nunotmp.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • November 14, 2014 at 2:41 pm #131560
    horizonsofchaos
    Participant

    I'm trying to figure out how to accomplish this task but I've hit a dead end and I'm not sure where to go from here. I used the following code I referenced from one of Brad Dalton's tutorials to show the featured image on Single Posts:

    //Featured Image on Single Post
    add_action( 'genesis_entry_header', 'single_post_featured_image', 15 );
    
    function single_post_featured_image() {
    	
    	if ( ! is_singular( 'post' )  ) 
    		return;
    	
    	$img = genesis_get_image( array( 'format' => 'html', 'size' => genesis_get_option( 'image_size' ), 'attr' => array( 'class' => 'post-image' ) ) );
    	printf( $img ); 
    	
    } 

    What I'd like to do is have the featured image show on all single posts except for those with the parent category of "Photos." As I understand it this should use a conditional but I just don't know how to write it. Any ideas or any clues on where to look?

    http://monstermagicmt.com/test2/
    November 15, 2014 at 2:58 pm #131654
    Brad Dalton
    Participant

    Link to the source of the code please.


    Tutorials for StudioPress Themes.

    November 15, 2014 at 3:05 pm #131657
    horizonsofchaos
    Participant

    This is the tutorial of yours I referenced: http://wpsites.net/web-design/display-featured-image-before-or-after-entry-title-on-single-posts-pages/

    Here is my functions.php code

    <?php
    //* Start the engine
    include_once( get_template_directory() . '/lib/init.php' );
    
    //* Child theme (do not remove)
    define( 'CHILD_THEME_NAME', 'Genesis Sample Theme' );
    define( 'CHILD_THEME_URL', 'http://www.studiopress.com/' );
    define( 'CHILD_THEME_VERSION', '2.1.2' );
    
    // Child theme library
    require_once(CHILD_DIR.'/lib/structure/lexicon_post.php');
    
    //* Enqueue Google Fonts
    add_action( 'wp_enqueue_scripts', 'genesis_sample_google_fonts' );
    function genesis_sample_google_fonts() {
    
    	wp_enqueue_style( 'google-fonts', '//fonts.googleapis.com/css?family=Lato:300,400,700', array(), CHILD_THEME_VERSION );
    
    }
    
    //* Add HTML5 markup structure
    add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list' ) );
    
    //* Add viewport meta tag for mobile browsers
    add_theme_support( 'genesis-responsive-viewport' );
    
    //* Add support for custom background
    add_theme_support( 'custom-background' );
    
    //* Add support for 3-column footer widgets
    add_theme_support( 'genesis-footer-widgets', 3 );
    
    // Add new image sizes
    add_image_size('Slideshow', 600, 300, TRUE);
    add_image_size('Small Thumbnail', 70, 70, TRUE);
    add_image_size('Medium Thumbnail', 250, 166, TRUE);
    add_image_size('Photos Page Thumbnail', 150, 100, TRUE);
    
    // Changing excerpt more 
    add_filter('excerpt_more', 'new_excerpt_more'); 
    function new_excerpt_more($more) { 
        return '&hellip;<br /><span class="more-link-wrapper"><a href="'.get_permalink().'" class="more-link">Read More</a></span>'; 
    }
    
    // Alter Post Byline
    remove_action('genesis_before_post_content','genesis_post_info');
    add_action('genesis_before_post_content','lexicon_post_info');
    
    // Remove Post Meta
    remove_action('genesis_after_post_content', 'genesis_post_meta');
    
    //* Enqueue sticky menu script
    add_action( 'wp_enqueue_scripts', 'sp_enqueue_script' );
    function sp_enqueue_script() {
    wp_enqueue_script( 'sample-sticky-menu', get_bloginfo( 'stylesheet_directory' ) . '/js/sticky-menu.js', array( 'jquery' ), '1.0.0' );
    }
     
    //* Reposition the secondary navigation menu
    remove_action( 'genesis_after_header', 'genesis_do_subnav' );
    add_action( 'genesis_before', 'genesis_do_subnav' );
    
    //Enables use of images in widget title box
    function genesis_widget_title( $title ) {
         if( preg_match( '|^https?://|', $title ) )
                 return "<img src='{$title}' />";
         return $title;
    }
    add_filter( 'widget_title', 'genesis_widget_title' );  
    
    // Register responsive menu script
    add_action( 'wp_enqueue_scripts', 'genesis_enqueue_scripts' );
    /**
    * Enqueue responsive javascript
    * @author Ozzy Rodriguez
    * @todo Change 'prefix' to your theme's prefix
    */
    function genesis_enqueue_scripts() {
     
    wp_enqueue_script( 'genesis-responsive-menu', get_stylesheet_directory_uri() . '/lib/js/responsive-menu.js', array( 'jquery' ), '1.0.0', true ); // Change 'prefix' to your theme's prefix
     
    }
    
    //Featured Image on Single Post
    add_action( 'genesis_entry_header', 'single_post_featured_image', 15 );
    
    function single_post_featured_image( ) {
    	
    	
    	if ( ! is_singular( 'post' )   )  
    		return;
    	
    	$img = genesis_get_image( array( 'format' => 'html', 'size' => genesis_get_option( 'image_size' ), 'attr' => array( 'class' => 'post-image' ) ) );
    	printf( $img ); 
    	
    } 
    
    //Featured Image on Category Archive
    //Home Page News Posts
    add_action( 'genesis_before', 'child_conditional_actions' );
    function child_conditional_actions() {
        if( is_category( 'photos' ) || is_category( '2015-photos' ) || is_category( '2014-photos' ) || is_category( '2013-photos' ) || is_category( '2012-photos' ) || is_category( '2011-photos' ) || is_category( '2010-photos' ) || is_category( '2009-photos' ) || is_category( '2008-photos' ) || is_category( '2007-photos' ) || is_category( '2006-photos' ) || is_category( '2005-photos' ) || is_category( '2004-photos' )  ) {
            remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
            add_action( 'genesis_entry_content', 'photos_archive_featured_image', 8 );
        }
    	
    }
    
    function photos_archive_featured_image() {
    	
    	$img = genesis_get_image( array( 'format' => 'html', 'size' => 'Photos Page Thumbnail', 'attr' => array( 'class' => 'alignleft post-image' ) ) );
    	printf( $img ); 
    }
    November 15, 2014 at 3:18 pm #131660
    nunotmp
    Member

    You need to use the conditional in_category() so this should work.

    
    function single_post_featured_image() {
    	
    	if ( ! is_singular( 'post' )  ||  in_category( 'photos' ) ) 
    		return;
    	
    	$img = genesis_get_image( array( 'format' => 'html', 'size' => genesis_get_option( 'image_size' ), 'attr' => array( 'class' => 'post-image' ) ) );
    	printf( $img ); 
    	
    }
    

    Genesis Child Themes – Follow Me

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble