- This topic has 22 replies, 3 voices, and was last updated 4 years ago by
Tom.
-
AuthorPosts
-
March 7, 2019 at 11:35 am #832060
Dax
Hello,
I like the streamlined look of the page hero and would like to achieve something for all of my pages.
I would like to be able to place the H1 titles of pages (and be left-aligned) along with a featured image (right aligned) within a single block of color like a page hero.
What would the best way to achieve this be?
Thank you
March 7, 2019 at 4:03 pm #832278Tom
Lead DeveloperLead DeveloperHi there,
I would use Header Element for this: https://docs.generatepress.com/article/header-element-overview/
You can output the H1 of the page using
{{post_title}}
.Then you can output the featured image like this:
{{custom_field._thumbnail_id}}
Let me know if you need more info π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 7, 2019 at 5:01 pm #832325Dax
Thanks, that seems to be working, only I can’t align the thumbnail, it is being pushed below the h1 so that they are being stacked on top of one another. I have no coding knowledge, unfortunately so I’m sure I’ve missed something that’s easy to fix.
Sorry to be a pain, but is there any way to stylize the thumbnail too? As in change, it’s radius etc?
March 7, 2019 at 5:06 pm #832331Tom
Lead DeveloperLead DeveloperTry this:
<div class="page-hero-stuff"> <div class="page-hero-title"> {{post_title}} </div> <div class="page-hero-image"> {{custom_field._thumbnail_id}} </div> </div>
Then add this CSS:
.page-hero-stuff { display: flex; } .page-hero-title { margin-right: auto; } .page-hero-image img { border-radius: 50px; }
Just a guess without being able to see the site π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 8, 2019 at 7:08 am #832923Dax
Thanks, that worked perfectly! How would I switch it off for the mobile version?
March 8, 2019 at 8:14 am #833015David
StaffCustomer SupportHi there,
you can use media queries:
https://docs.generatepress.com/article/responsive-display/
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/March 8, 2019 at 11:01 am #833201Dax
Hello David,
Thanks, I inserted the hide-on-mobile in the page hero element, which works. However, I would like the mobile version to have both a featured image and title stacked above each other.
Do I need to create a separate code like the above and a separate element with the hide-on-desktop classification?
March 8, 2019 at 11:09 am #833207David
StaffCustomer SupportInstead of hiding it on mobile – so you can remove that, we just limit Toms CSS to desktop like so:
@media (min-width: 1025px) { /* CSS in here for desktop only */ .page-hero-stuff { display: flex; } .page-hero-title { margin-right: auto; } } /* This applies to all sizes */ .page-hero-image img { border-radius: 50px; }
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/March 9, 2019 at 6:48 am #833749Dax
Thanks for that, I appreciate it.
Is there any way to make the featured image/thumbnails look better? Not sure how to put it in technical terms but their quality/size/resolution varies from page to page.
Some seem to be getting stretched, others squashed.
March 9, 2019 at 7:14 am #833900Dax
Another thing too: How would I go about adding meta information into the page hero area? I would like it to be below the H1 title. For instance the post author, tags and date last updated ( I currently use a plugin for the date – the last modified date plugin)
Thanks in advance!
March 9, 2019 at 9:50 am #833995David
StaffCustomer SupportCan you provide a link to the Site so we can see the first issue. You can edit your original topic and use the Site URL field for privacy.
The second one, you can add {{template_tags}} in the header for the meta etc:
https://docs.generatepress.com/article/header-element-template-tags/
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/March 9, 2019 at 11:21 am #834062Dax
Added it,
Thanks!
March 9, 2019 at 5:22 pm #834202Tom
Lead DeveloperLead DeveloperAre there specific pages where we can see squished ones vs good ones? I wasn’t able to find any.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 10, 2019 at 10:44 am #834794Dax
Hi Tom,
Here are some examples:
I’m not sure of the cause, maybe it’s the dimensions of the original image? Either way, somehow I would like a consistent look across the site e.g. in terms of image size and H1 title position. How would you suggest I achieve this goal?
As well as size and position, is there anyway to stylize the images better? I was thinking they may look better if they were the same height as the page hero? Perhaps with a diagonal clipping effect?
March 10, 2019 at 5:02 pm #835015Tom
Lead DeveloperLead DeveloperYes, you’d need to upload images that are:
1. Big enough to fit the area
2. The same dimensions so it’s consistentThen you could remove the padding from the page hero element itself using the settings, and adjust your original CSS to this:
@media (min-width: 1025px) { /* CSS in here for desktop only */ .page-hero-stuff { display: flex; align-items: center; } .page-hero-title { margin-right: auto; padding: 20px; } } @media (max-width: 1024px) { .page-hero-title { padding: 20px; } .page-hero-image { text-align: center; margin-top: 20px; } }
If you want to automatically size your images, you could do this:
add_action( 'after_setup_theme', function() { add_image_size( 'hero-image', 500, 500, true ); } ); add_filter( 'generate_hero_thumbnail_id_size', function() { return 'hero-image'; } );
Adding PHP: https://docs.generatepress.com/article/adding-php/
Once you add that PHP, you’ll need to re-generate your thumbnails so existing images update to the correct size using a plugin like this: https://wordpress.org/plugins/regenerate-thumbnails/
Hope this helps π
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.