-
Greetings:
To improve user engagement on the website, I’d like to display featured image’s thumbnail along with previous/next post links at the bottom of every post.
Please guide how to accomplish this using the GP Premium theme.
Thank you.
-
Fernando
Hi Sam,
This article should be helpful regarding this: https://docs.generatepress.com/article/block-element-post-navigation/
-
Do I need to be using block editor for this?
-
Please note that the website still uses the Classic Editor and I intend to keep it that way.
Please suggest a resolution keeping above in mind.
Thanks.
-
Fernando
Yes, you would need to use the Block Editor.
Unfortunately, without using the Block Editor, you’ll need a custom code. This would be out of our scope of support though.
-
Thanks for your response.
I did some research. Will the code listed on following link work if added to functions.php?
Link: https://gist.github.com/generatepress/dc79fa83d8706f19365aa07ddd141cd3
-
Hi there,
You can give it a try.
The function doesn’t specify the size of the image though, you might need extra CSS or change the code a bit to add size attribute.
For example, you can change these 2 lines:
$prevThumbnail = isset( $prevPost ) ? get_the_post_thumbnail( $prevPost->ID ) : ''; $nextThumbnail = isset( $nextPost ) ? get_the_post_thumbnail( $nextPost->ID ) : '';
to:
$prevThumbnail = isset( $prevPost ) ? get_the_post_thumbnail( $prevPost->ID, array( 300, 200 ) ) : ''; $nextThumbnail = isset( $nextPost ) ? get_the_post_thumbnail( $nextPost->ID, array( 300, 200 ) ) : '';
So the output images will be 300px * 200px, feel free to change the values 🙂
- You must be logged in to reply to this topic.