I want to pull a blog post meta descritption for a post listing module I am designing for our homepage. Does anyone know of a way to do this? Or is there a way to truncate the body content to a certain character count?
Here is the module I am building:
{% set posts = blog_recent_posts ('default', 3) %}
{% for post in posts %}
<div class="background_focus_image span4 widget-span" style="background:linear-gradient(0deg, rgba(000,000,000,0.5), rgba(000,000,000,0.5)) repeat ,url({{ post.post_list_summary_featured_image }}) no-repeat center bottom; background-size: cover;">
<div class="homepage_title_backer">
<h2><a href="{{ post.absolute_url }}">{{ post.name }}</a></h2>
</div>
<div class="homepage_desc">
<p>{{ meta description or truncated contnet would go here }}</p>
</div>
<div class="homepage_CTA">
<a href="{{ post.absolute_url }}" class="hs-button">Read More</a>
</div>
</div>
{% endfor %}
{{ content.meta_description }} is the tag to pull the meta description of a page - though if this is on the listing page it might just pull the listing page's description. {{ content.post_body|truncate(25) }} Will allow you to pull the post body and limit to a certain number of characters. 25 can be switched out to whatever limit you want (max of 255 characters).
{{ content.post_summary }} will print the blog post summary - this is what appears before the "read more" separator on your page.
{{ content.meta_description }} is the tag to pull the meta description of a page - though if this is on the listing page it might just pull the listing page's description. {{ content.post_body|truncate(25) }} Will allow you to pull the post body and limit to a certain number of characters. 25 can be switched out to whatever limit you want (max of 255 characters).
{{ content.post_summary }} will print the blog post summary - this is what appears before the "read more" separator on your page.
I'd love to know the if/else statement I can use to amend my blog Listing Template that will print anything entered in the Meta Description field OR use a truncated version of the body content (if nothing is entered in the Meta Description field).