Archived topic
Change excerpt Length and source
14 replies · Started by Dave on January 3, 2021
I would like to change where the excerpt is drawn from on my blog post page. Currently, I would have to enter an excerpt for each post separately. Is there a way to have it pull from the beginning of the post instead and then just continue into the post?
cheers,
Dave
Hi there,
By default, the auto excerpt should display when the custom excerpt metabox is not in used and there is customizer option for word count:
https://docs.generatepress.com/article/blog-content-layout/
Looks like it's working in this post?
https://www.screencast.com/t/m4aKYEbT
Thanks Leo, but that is not the excerpt that I am referencing. It is the excerpt that has been created on the post in the Private Information section. It is the single..php.
I belive the code I am using is drawing specifically from the excerpt and I would like to draw from the actual post.
cheers,
Dave
So you are referring to the excerpt in the page hero?
Are you currently using this snippet here?
https://docs.generatepress.com/article/page-hero-examples/#example-4
If so edit the PHP snippet to this:
function db_page_hero_excerpt() {
ob_start();
global $post;
?>
<div class="page-hero-excerpt">
<?php echo the_excerpt(); ?>
</div>
<?php
return ob_get_clean();
}
add_shortcode( 'page_hero_excerpt','db_page_hero_excerpt' );
I am actually wanting to replicate something like this: https://www.saltinourhair.com/tips/start-travel-blog/
So, maybe I should not be using an excerpt as I don't think it works in this instance. Any suggestions?
Cheers,
Dave
Do you have any idea how I would implement them to come up with the desired effect?
Cheers,
Dave
Just to make sure, you are referring to this part here?
https://www.screencast.com/t/UdEYBimHUjNz
If so the custom field method I mentioned above should be the way to go.
https://www.wpbeginner.com/wp-tutorials/wordpress-custom-fields-101-tips-tricks-and-hacks/
That is the section but I think this is way above my limited abilities at the moment :)
I will look for another solution.
cheers,
Dave
If I understand this correctly I will have to add it in for each post as it will be different for each one. I have over 500 posts and don't want to do it for each one :)
Is there another solution?
cheers,
Dave
You will only have to add the custom field once in the page hero, but yes each custom field will need to be added within the posts itself.
There isn't another solution unfortunately.
Is it possible just to move the featured image to the right and above the sidebar?
That way the post can continue under the title?
cheers,
Dave
Can you open a new topic for the separate question?
Thanks!
I actually already did :)
Cheers,
Dave
Thanks!
We will get to it :)