Community Forums › Forums › Archived Forums › General Discussion › A featured image for individual categories
Tagged: category pages, featured images
- This topic has 8 replies, 2 voices, and was last updated 8 years, 3 months ago by Brad Dalton.
-
AuthorPosts
-
August 22, 2016 at 10:57 am #191794studionooblyMember
So I know that you can add a some cool things to a category/archive page like headlines and content but I would really like to add a featured image which I could then place in the header of said category, is this possible? (note I have already got the code that adds featured images to the header I just need to be able to assign a featured image to a category.)
Thanks,
http://n/aAugust 22, 2016 at 11:03 am #191795Brad DaltonParticipantAugust 22, 2016 at 11:53 am #191805studionooblyMemberCool thanks, I'll have a look but would prefer to do it with no plugins.
August 22, 2016 at 11:58 am #191806Brad DaltonParticipantAre you referring to adding a different header image to category archive pages?
Or a different header to posts in different categories
Or using featured images from single posts as different headers?
Also, can you embed the code you have already that adds featured images to the header
August 22, 2016 at 12:56 pm #191812studionooblyMemberYea I'd like to add a different header image to each of the category archive pages - so the way I would envisage it would be the user clicks on Category settings and somewhere in there they could add a featured image to the category.
This is the current code that adds featured images to the header
add_action( 'genesis_entry_header', 'themeprefix_featured_image', 1 ); function themeprefix_featured_image() { $image = genesis_get_image( array( // more options here -> genesis/lib/functions/image.php 'format' => 'html', 'size' => 'large',// add in your image size either a custom one or a default - https://codex.wordpress.org/Post_Thumbnails 'context' => '', 'attr' => array ( 'class' => 'aligncenter' ), // set a default WP image class ) ); if ( is_singular() || is_page() ) { if ( $image ) { printf( '<div class="featured-image">%s</div>', $image ); // wraps the featured image in a div with css class you can control } } }
August 22, 2016 at 1:08 pm #191814Brad DaltonParticipantAre your referring to the entry header or site header? The code you posted hooks a featured image added to the featured image meta box on single posts to the entry header which is where the single post entry title is.
Also, featured images are unique to each single post. I assume you mean adding a unique image ( not featured image ) to the site header, not the entry header?
August 22, 2016 at 1:32 pm #191816studionooblyMemberYes a unique image but not in the site header currently I have the main menu there, I would need the image to go into the content just above the category title.
August 23, 2016 at 12:23 am #191851Brad DaltonParticipantUse the genesis before loop hook to hook in each image with the is_category conditional tag.
August 23, 2016 at 2:22 am #191854Brad DaltonParticipantHere's 2 complete solutions i spent a few hours coding for members.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.