- This topic has 9 replies, 4 voices, and was last updated 4 months, 1 week ago by
Elvin.
-
AuthorPosts
-
September 11, 2020 at 8:59 am #1439584
roy
hi, i would like my main hero header to be on my category pages as well but i don’t have category pages to put them as a featured image.
please let me know, thanks!
September 11, 2020 at 9:51 am #1439643Leo
StaffCustomer SupportHi there,
You would need to create a separate page hero/header element and use the custom image option instead:
https://docs.generatepress.com/article/header-element-overview/#background-imageLet me know if this helps π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 11, 2020 at 11:52 am #1439769roy
I am a little confused as it requires some coding, could I get some clarification? Sorry, not a coder π
September 11, 2020 at 2:08 pm #1439894Tom
Lead DeveloperLead DeveloperHi there,
Just to confirm, are you wanting to add featured images to your category archives, and have those featured images display as the page hero background?
If so, this topic may help: https://generatepress.com/forums/topic/advance-custom-field-image-for-my-category-archive-header-element-background/
Let us know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentSeptember 11, 2020 at 10:12 pm #1440092roy
Hi Tom!
I just tried to follow everything Samantha did but with no success.
I wouldn’t mind if my category pages show the same header as my homepage, I am just confused on how to set this?
I made a custom page with the code, made it the same settings as the other heros, then I went to download ACF and attempted to get it working but still in the same place. When you click on the link I provided it’s just the grey box but I want them to have a picture as well to clarify.
Thanks!
September 11, 2020 at 10:47 pm #1440100Elvin Customer Support
Hi Roy,
You can try copying these settings:
For ACF Field group rules:
https://share.getcloudapp.com/bLuRPY6D (you can add more rules if you want the field to appear on pages and tags taxonomy too.)For ACF image field settings:
https://share.getcloudapp.com/jkuZNgrXAdding Category Page Featured Image: (this image field will only appear after you add it on ACF)
https://share.getcloudapp.com/12uJZxBqPage Hero/Header Element settings:
https://share.getcloudapp.com/NQurGREG – (Remove the inline style on h1 and add your own css class.)
https://share.getcloudapp.com/P8ubP0jd
https://share.getcloudapp.com/bLuRPYok – (you can change this to Post Category Archive if you only want it to display on Category Archive Pages)PHP code to add on Code Snippet:
function get_acf_category_featured_image( $url ) { $term = get_queried_object(); $background_image = get_field('category_featured_image', $term); if ( $background_image ) { $url = $background_image; } return $url; } add_action('wp', function(){ if(is_archive()){ add_filter( 'generate_page_hero_background_image_url', 'get_acf_category_featured_image' ); } });
As previously mentioned, this code checks if the page is an archive page and uses the image from the custom field if it is an archive page. Else, it will let the page use the default featured image used by the page.
Note: If you have a different custom field name for your image field, replace the
'category_featured_image'
text inside$background_image = get_field('category_featured_image', $term);
to match your image’s custom field name.Let us know if this helps. Hope this makes things easier to follow.:)
A wise man once said:
"Have you cleared your cache?"September 11, 2020 at 11:03 pm #1440107roy
“Page Hero/Header Element settings:
https://share.getcloudapp.com/NQurGREG β (Remove the inline style on h1 and add your own css class.)”this is the only part I am confused about, what exactly should I be typing in the box? the same as you have written there?
September 11, 2020 at 11:16 pm #1440125roy
Sorry! I fixed it just now with the detailed guide you posted. Thank you so much!!!
September 11, 2020 at 11:24 pm #1440127Elvin Customer Support
βPage Hero/Header Element settings:
https://share.getcloudapp.com/NQurGREG β (Remove the inline style on h1 and add your own css class.)βthis is the only part I am confused about, what exactly should I be typing in the box? the same as you have written there?
It really depends on what you want displayed there.
<h1 style="text-align: center; color: #222222; font-size: 50px;"> {{post_title}} </h1>
This code dynamically displays the Page Title or the taxonomy name(Category Name, Tag Name).
If you want a static text that displays on all pages specified on your Page Element’s Display Rule, you can simply replace
{{post_title}}
with whatever text you want displayed.Example:
<h1> THIS IS MY SITE. </h1>
This code will simply display “THIS IS MY SITE.” inside the page header.
Hope this sheds more light.
Let us know if you have further questions.:)
A wise man once said:
"Have you cleared your cache?"September 11, 2020 at 11:26 pm #1440128Elvin Customer Support
Nice one.
No problem. I’m glad you figured it out. π
A wise man once said:
"Have you cleared your cache?" -
AuthorPosts
- You must be logged in to reply to this topic.