- This topic has 9 replies, 2 voices, and was last updated 3 years, 11 months ago by David.
-
AuthorPosts
-
May 18, 2020 at 10:02 pm #1291152Tan
Hi there,
I want to show feature image, author name, updated date and social share on post hero like Ahrefs blog: https://ahrefs.com/blog/nofollow-ugc-sponsored/
What could I do now?
Thank you so much!May 19, 2020 at 2:40 am #1291468DavidStaffCustomer SupportHi there,
we helped someone with a similar request here:
https://generatepress.com/forums/topic/customization-help-featured-image-text/#post-1270406
Points 1, 2 and 2.1 will give you the basics of how to add a featured image inside a header element.
Give that a go and let us know.
May 19, 2020 at 7:39 am #1291929TanThank you David. It worked well. 🙂
I want specific size of feature image. How can I customize it?
And I want to show: “avatar author name | Updated date | Social share” under post title. Could you help me?May 19, 2020 at 8:12 am #1292157DavidStaffCustomer Support1. This line of the code:
$img_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large', false );
You can replace
large
with any of the media thumbnail sizes you have.This function allows you to add your own size if you require:
https://developer.wordpress.org/reference/functions/add_image_size/
2. A few steps are required for that layout:
This hero example shows how to add the Avatar | author | post date :
https://docs.generatepress.com/article/page-hero-examples/#example-2
To make the date show Updated requires this PHP Snippet:
The Social Share icons you will require a plugin that provides a short code option ( most of em do )
May 19, 2020 at 8:43 am #1292221TanI’m not familiar with the code :(. I want to show w=720px, h=auto. Could you help me with the code?
Thank you so much!May 19, 2020 at 8:52 am #1292236DavidStaffCustomer SupportThis article explains:
https://docs.generatepress.com/article/adding-image-sizes/
So you could add this:
add_action( 'init', function() { add_image_size( 'hero', 720 ); // 720px wide - auto height } );
Then you can change this line in the shortcode to:
$img_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'hero', false );
May 19, 2020 at 11:39 pm #1293197TanIt did not change the size of feature image. Could you check again?
May 20, 2020 at 12:48 am #1293260DavidStaffCustomer SupportDid you regenerate thumbnails like the doc said:
The last thing you need to do is regenerate your thumbnails. WordPress doesn’t do this by default, so it’s necessary to use a plugin like this.
Link to plugin:
https://en-gb.wordpress.org/plugins/regenerate-thumbnails/May 20, 2020 at 1:21 am #1293285TanYes. It worked. I missed it! Thank you so much David! 🙂
May 20, 2020 at 3:46 am #1293463DavidStaffCustomer SupportYou’re welcome – looks great 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.