-
YEAR93
Hello,
Is it possible to place the first paragraph of the blog posts in the Single Post Hero element, followed by the featured image of each post? If so, how can this be achieved? This website has a layout similar (on mobile) to what I want: https://www.alzheimer-nederland.nl/nieuws/casemanagement-dementie-al-verzekerde-zorg-vanaf-niet-pluis-fase. They first display the post title in the Post Hero, followed by the intro paragraph of the post, then the featured image, and finally the rest of the post text.
Additionally, I’d like to know if it’s possible to set the padding-top to 0px on the single blog post page content.
-
Hi there,
You can add the 1st paragraph into the custom except field, and use a headline block to pull the excerpt in the page hero.
If you do not want to manually remove the 1st paragraph from the post content, you can use CSS to hide it on the front end.
Additionally, I’d like to know if it’s possible to set the padding-top to 0px on the single blog post page content.
Try this CSS:
.one-container.single-post .site-content { padding-top: 0; }
-
YEAR93
Hello,
Thank you for your reply. I’ve added an excerpt field to my Single Post Hero element block, but it now overrides the excerpt length on the blog archive page. If I may ask, do you know what’s best for SEO? Should I remove the first paragraph or hide it?
-
I’m not an expert on SEO, you might want to do some research for this, sorry.
For the excerpt length issue, you can use this PHP code to trim it, change 20 to the word count you want.
add_filter( 'wp_trim_excerpt', 'yh_trim_custom_excerpt' ); function yh_trim_custom_excerpt( $excerpt ) { $output = $excerpt; // Limit word count to 20 $words_limit = 20; $excerpt_words = preg_split('/[\s]+/', $excerpt, $words_limit + 1); if (count($excerpt_words) > $words_limit) { array_pop($excerpt_words); $excerpt = implode(' ', $excerpt_words); } if ( has_excerpt() ) { $output = sprintf( '%1$s...', $excerpt, get_permalink(), __( 'Read more', 'generatepress' ) ); } return $output; }
However, if you don’t want to use custom excerpt, you can also add the 1st paragraph to a custom field, and use the GB headline block to pull post meta > your_custom_field_slug.
-
YEAR93
Hello,
I believe the custom field option will be better. Is this what you are referring to: https://www.wpbeginner.com/wp-tutorials/wordpress-custom-fields-101-tips-tricks-and-hacks/
-
Yes 🙂
-
YEAR93
Thank you. I’ve added the first paragraph to a custom field and used the GB headline block to pull the post meta > your_custom_field_slug as Ying suggested. This method works perfectly!
-
No problem 🙂
- You must be logged in to reply to this topic.