• 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

Use 2 Different Featured Image Sizes In Content Archives 1 for Blog & 1 for CPT?

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 › Design Tips and Tricks › Use 2 Different Featured Image Sizes In Content Archives 1 for Blog & 1 for CPT?

This topic is: resolved

Tagged: content archives, content_archive_thumbnail, featured image filter, featured images, post_thumbnail

  • This topic has 4 replies, 2 voices, and was last updated 8 years, 1 month ago by Brad Dalton.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • April 13, 2017 at 1:39 am #204711
    SeoGreenPea
    Member

    I have a custom post type called "books". I have created a taxonomy type "book-type". Each taxonomy has it's own archive, fairly standard stuff. But I want my featured image for books to be based on the following "add_image_size"....

    add_image_size( 'book', 150, 200, TRUE );

    On my standard blog posts, I still want to be able to select from the "Genesis/Theme Settings/Content Archives/Featured Image, which may include for example, home-middle (380x380).

    If I select home-middle (380x380), that works perfectly for my standard blog posts, but unfortunately, it's also adapting to my "books" archives.

    I want my "books" archives to use a featured image that is using the size 'book'.

    I have no clue...
    Does Genesis have a filter for featured images?
    post_thumbnail, content_archive_thumbnail, etc...

    Anyone have a solution?

    Thanks.

    April 13, 2017 at 11:21 pm #204766
    Brad Dalton
    Participant

    Link to the CPT archive in question please.


    Tutorials for StudioPress Themes.

    April 14, 2017 at 8:45 am #204789
    Brad Dalton
    Participant

    Here's 2 different solutions


    Tutorials for StudioPress Themes.

    April 15, 2017 at 9:02 am #204825
    SeoGreenPea
    Member

    Thank you Brad, but I've come up with my own solution. I'm sure your solution is probably better, but this is what I was able to use that allowed me to accomplish the end result I was after.

    // This removes the featured image from books archive entries
    add_action('genesis_before_loop','custom_remove_book_featured_image');
    function custom_remove_book_featured_image() {
    	if ( is_post_type_archive( 'books' ) || is_archive() && is_tax( 'book-type' ) ) {
    remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
    	}
    }
    
    // This adds the featured image size ‘book’ to my books archive entries
    add_action( 'genesis_entry_content', 'custom_add_book_featured_image', 1 );
    function custom_add_book_featured_image() {
    	global $post;
    	if ( is_post_type_archive( 'books' ) || is_archive() && is_tax( 'book-type' ) ) {
    	if ( $image = genesis_get_image( 'format=url&size=book' ) ) {
    		printf( '<div class="featuredbookimage"><img src="%s" alt="%s" class="aligncenter" itemprop="image" /></div>', $image, the_title_attribute( 'echo=0' ) );
    	}
    	else {
    		printf( '<div class="featuredbookimage"><img src="%s" alt="%s" class="aligncenter" /></div>', get_bloginfo( 'stylesheet_directory' ) . '/images/noimage200200.png', the_title_attribute( 'echo=0' ) );
    	}
    
    }
    }
    April 15, 2017 at 9:06 am #204826
    Brad Dalton
    Participant

    Thats alright. Always different ways to code the same solution.


    Tutorials for StudioPress Themes.

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Use 2 Different Featured Image Sizes In Content Archives 1 for Blog & 1 for CPT?’ is closed to new 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