- This topic has 10 replies, 4 voices, and was last updated 3 years, 5 months ago by Elvin.
-
AuthorPosts
-
November 4, 2020 at 7:31 am #1517840Samuel
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,
SamuelNovember 4, 2020 at 8:33 am #1517931LeoStaffCustomer SupportHi 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.
November 4, 2020 at 9:04 am #1517979SamuelHi 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
November 4, 2020 at 1:05 pm #1518236TomLead DeveloperLead DeveloperHi there,
This might help: https://generatepress.com/forums/topic/using-plugin-to-get-images-in-element-for-category-pages/#post-778465
November 4, 2020 at 1:24 pm #1518263SamuelHi 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.
November 4, 2020 at 1:33 pm #1518272ElvinStaffCustomer SupportHi,
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/November 4, 2020 at 1:52 pm #1518286November 4, 2020 at 1:59 pm #1518290SamuelHere is what I did
November 4, 2020 at 3:11 pm #1518346ElvinStaffCustomer SupportInstead 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.November 5, 2020 at 12:42 am #1518602SamuelThanks Elvin, that was it !
November 5, 2020 at 12:29 pm #1519660ElvinStaffCustomer SupportThanks Elvin, that was it !
No problem. π
-
AuthorPosts
- You must be logged in to reply to this topic.