Archived topic
Featured image on Archive page
10 replies · Started by Samuel on November 4, 2020
Hi,
Is this possible to add a "uploadable featured image" option in archive edition page ?
And then be able to call it with Element hook to display ii in an Archive page header ?
Thanks for your help,
Samuel
Hi there,
Unfortunately not - WordPress ignores all metabox values on archive/posts pages so the featured image option won't work.
You will just need to use the Custom image option in the header element.
Hi Leo,
I will continue like if there was a solution to find here ok ? ;-)
I looked a little bit more at this problem and I found some informations from Tom and David here in the forum.
To add featured image option to an Archive there is a plugin called "Category Image".
This plugin offers a function to display the featured image :
<?php if (function_exists('z_taxonomy_image')) z_taxonomy_image(); ?>
So it seems to be possible. ;-)
Now I need help to use this function in a Header element.
I need a hero style header and to display this image like a normal "featured image" would display. Or to be more specific like this : http://test.lesventsnousportent.com/sobre-nosotros/
If I just call this image using a Hook like generate-header or other solutions I tried it's displaying like this : http://test.lesventsnousportent.com/turismo/cultura/
Could you help me find the proper solution here please ?
Thanks a lot
Hi there,
This might help: https://generatepress.com/forums/topic/using-plugin-to-get-images-in-element-for-category-pages/#post-778465
Hi Tom,
I tried this solution as well but it's not working, can you validate my workflow
I put the function in a Hook element wp_head, displaying on archive pages :
add_filter( 'generate_page_hero_background_image_url', function( $url ) {
if ( is_category() && function_exists( 'z_taxonomy_image_url' ) ) {
$image = z_taxonomy_image_url();
if ( $image ) {
return $image;
}
}
return $url;
} );
Then I create a Header element with "featured image" ON and displaying on Archive Pages.
But no image is displaying front-end.
Hi,
Perhaps these topics can help you.
Adding featured image to archive page's header element.
https://generatepress.com/forums/topic/how-do-i-get-the-header-on-the-category-pages/#post-1440100
https://generatepress.com/forums/topic/advance-custom-field-image-for-my-category-archive-header-element-background/
Thanks @Elvin, I followed this step by step without any result.
Here is what I did







Instead of adding the PHP snippets through a Hook Element, add the PHP snippets by following this guide: https://docs.generatepress.com/article/adding-php/
We recommend using Code Snippets plugin if you don't want to use a Child theme's functions.php to add your snippets.
Thanks Elvin, that was it !
Thanks Elvin, that was it !
No problem. :)