How to show a featured image on in an archive view?
- This topic has 7 replies, 2 voices, and was last updated 4 years, 10 months ago by
EddyPiV.
-
AuthorPosts
-
June 26, 2020 at 2:09 PM #20507
EddyPiV
ParticipantHi,
With MT Term Meta I have added featured images to my categories and custom taxonomies.
I would like to see these replacing the header images from my theme when showing the archive pages for the categories / taxonomies.
My theme doesn't recognize this term meta added field (obviously), and the closest I got with MB Views was to render The whole page layout, including header and footer. But then I am losing also the main menu and my widget area's. Even my website name and flavicon disappear.
How to replace the theme's header image with the featured image of the term?June 26, 2020 at 2:46 PM #20509Long Nguyen
ModeratorHi Eddy,
What is the theme that you are using? If it is premium theme, please send a copy of this theme to this support form https://metabox.io/contact/. I can help you to replace the header image with the image of the custom field after looking into the code of the theme.
June 26, 2020 at 7:09 PM #20513EddyPiV
ParticipantHi,
Yes I am using a Pro theme. Trying to send it to you, but the recaptcha on the contact page is hard to pass, as the header with the instruction whhat to do is not shown properly. see attached. https://share.getcloudapp.com/2Nu5Ppv2
So if you can help me there first...
June 26, 2020 at 7:14 PM #20514EddyPiV
ParticipantJust managed to send it to you through another browser.
June 27, 2020 at 9:46 AM #20524Long Nguyen
ModeratorHi Eddy,
I've checked the code of the theme Materialis Pro and find a way to change the default background image of the archive page with the image of a custom field.
- Create a simple image field such as
single_image
and assign it to a taxonomy. - Add this code to the file functions.php in the child theme folder.
add_action( 'materialis_before_header_background', function() { $term_id = get_queried_object_id(); $feature_image = rwmb_meta( 'single_image', array( 'object_type' => 'term' ), $term_id ); if( !empty( $feature_image ) ) { ?> <style type="text/css"> .header-wrapper .header { background-image: url(<?php echo $feature_image['full_url']?>) !important; } </style> <?php } } );
For more information, please follow the documentation below.
https://docs.metabox.io/extensions/mb-term-meta/#getting-field-value
https://docs.metabox.io/fields/single-image/June 27, 2020 at 11:22 PM #20546EddyPiV
ParticipantHi Long, thanks so much for your help. Much appreciated.
I noticed that within the archive view, for render "Only the post content area" it does not show the featured image. Actually, none of my settings are applied. It seems completely ignored.
For render "The layout between header and footer" the featured image is shown, but after the theme's header image, not replacing it.
I am not a real developer, so I prefer to stick as close as possible the the theme, hence using render "Only the post content area". But how to have my view settings applied, as well as the featured image replacing the theme's header image?
I hope you can help me further.
June 28, 2020 at 9:22 AM #20547Long Nguyen
ModeratorHi,
The theme uses the CSS code to display the image as a background cover image that's why I need to check the code and the code in my previous reply uses the CSS code to override the theme's style. See my screenshots for more information.
https://share.getcloudapp.com/yAuYkK7x
https://share.getcloudapp.com/NQugxNkZJuly 2, 2020 at 2:59 PM #20595EddyPiV
ParticipantHi Long, the developer of the theme has provided me with a solution.
Thanks for your help. - Create a simple image field such as
-
AuthorPosts
- You must be logged in to reply to this topic.