- This topic has 13 replies, 4 voices, and was last updated 3 years, 7 months ago by
Tom.
-
AuthorPosts
-
September 25, 2018 at 10:54 am #686136
Tomasz
I’m struggling with displaying featured image on blog posts. Currently, I have page header off (on blog posts) but ideally would like to display such image when it’s on as well.
So far I have: created an element (“Single blog post header”) that created page header with the featured image – but this didn’t help.GP Premium 1.7.2September 25, 2018 at 4:30 pm #686338Leo
StaffCustomer SupportHi there,
The featured image isn’t showing is because you are using Sections add-on which removes all the default elements – it is supposed to be a page builder.
Had a look at the page you linked and you shouldn’t need to use Sections.
The content you have in Section 2 should be a footer widget:
https://docs.generatepress.com/article/footer-widgets/And the content in Section 3 should be a copyright or footer bar widget area:
https://docs.generatepress.com/article/changing-the-copyright-message/
https://docs.generatepress.com/article/footer-bar-widget-area/Let me know if this helps π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 26, 2018 at 12:33 am #686490Tomasz
Hey, I planned to change structure of the page later on but didn’t know that using sections has such impact. Good incentive now.
But…. is there any way around? Sometimes using sections seems like a good idea.September 26, 2018 at 1:20 am #686509David
StaffCustomer SupportHi there,
check out the Header Element, this allows you to add the featured image plus other features:
https://docs.generatepress.com/article/header-element-overview/
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 26, 2018 at 8:10 am #686899Tomasz
David, as I wrote in the first post, I had created a Header Element specifically for blog posts. It doesn’t work – at least the background image (featured image) doesn’t show up. Should the Element (and hence featured image) work if I am using sections? Can you check what might be wrong?
September 26, 2018 at 8:32 am #686917Leo
StaffCustomer SupportHeader Element should work for sections as well.
I’m not seeing one being added to the page linked though?
Let us know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 26, 2018 at 8:49 am #686936Tomasz
Just checked. Element called: “Single blog post header” should be added to the page: blog post
September 26, 2018 at 10:18 am #687025Leo
StaffCustomer SupportHmm I just tested on my install and it definitely works.
Can you make sure the Display Rule is set for Post?
and make sure there aren’t other header elements that are causing the conflicts.
Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 26, 2018 at 12:05 pm #687105Tomasz
Both things checked
OK. Few things:
1.I have only one more element, which is for the parent – blog page. Just to test things out I turned it off to see if helps; it didn’t).
2. Except for two elements I have three legacy headers which are not used on this post page.
3. When you go to the blog page, it pulls featured image from this child post that I can’t get to work as I want.
4. I tried removing sections. Featured image works now. Still, I would like to be able to use these feature.
5. Featured image is set directly on the post page. Also feature image settings are set under Customise > Layout > Blog >Featured Images.September 26, 2018 at 6:45 pm #687285Tom
Lead DeveloperLead DeveloperTry this function:
add_action( 'generate_before_main_content', function() { $sections = get_post_meta( get_the_ID(), '_generate_sections', true ); if ( $sections && has_post_thumbnail() ) { echo '<div class="grid-container grid-parent featured-image">'; the_post_thumbnail(); echo '</div>'; } } );
Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentSeptember 26, 2018 at 10:41 pm #687352Tomasz
Tom, I’ve just added this code as a hook:
– before main content
– execute php: on
– display set to postEffect: This code appears just as a text above main content on the post page…
September 27, 2018 at 6:43 am #687680Tomasz
Progress:
-> I created widgets to abandon the use of sections on blog and post pages. Now featured image displays but a new problem arose. When I try to use the customizer to move the featured image below the title it doesn’t happen; instead, author and date of the post moves. Similar behavior doesn’t occur when I introduce other changes there, e.g. I can move an image to the left or right. It works properly.September 27, 2018 at 8:37 am #687864Tomasz
Is it so that featured image appears below a header but not a title? I tied using Firefox Inspector and it seems that I just have header space empty. That would explain things a bit.
September 27, 2018 at 10:03 am #687925Tom
Lead DeveloperLead DeveloperIf you’re adding it inside a Hook Element, you would do this:
<?php $sections = get_post_meta( get_the_ID(), '_generate_sections', true ); if ( $sections && has_post_thumbnail() ) { echo '<div class="grid-container grid-parent featured-image">'; the_post_thumbnail(); echo '</div>'; } ?>
Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.