CMS Development

HorusChild
Member

Last 3 blog posts on my site

SOLVE

Hello friends, I'm currently working on a project for my company, I have the section already made for this purpose, but as we will be having a blog I need my last 3 blog posts to be shown on this already built section of  the page, I have been researching and I found about tables but this would not be the solution needed since we need the last blog posts to be shown as we post them on the blog on a dynamic way, containing featured image, title and link to post, I haven't found a good solution for this, any ideas on this subject? Thank you so much in advance!

0 Upvotes
1 Accepted solution
Anton
Solution
Recognized Expert

Last 3 blog posts on my site

SOLVE

Hi @HorusChild

you can build a custom module with the blog_recent_post function. It will do exactly what you want to achieve. 

 

A very basic module can look like this

{% set rec_posts = blog_recent_posts("default", 3) %}
<div class="blogPostsWrapper">
{% for rec_post in rec_posts %}
<div class="singlePostWrapper">
<h4>{{ rec_post.name }}</h4>
<p class="postExcrept">{{ rec_post.post_body|striptags|truncate(150, '...', false) }}</p>
<a href="{{ rec_post.absolute_url }}" class="yourBtnClasses">read more</a>
</div>
{% endfor %}
</div>

 

best, 

Anton

Anton Bujanowski Signature

View solution in original post

1 Reply 1
Anton
Solution
Recognized Expert

Last 3 blog posts on my site

SOLVE

Hi @HorusChild

you can build a custom module with the blog_recent_post function. It will do exactly what you want to achieve. 

 

A very basic module can look like this

{% set rec_posts = blog_recent_posts("default", 3) %}
<div class="blogPostsWrapper">
{% for rec_post in rec_posts %}
<div class="singlePostWrapper">
<h4>{{ rec_post.name }}</h4>
<p class="postExcrept">{{ rec_post.post_body|striptags|truncate(150, '...', false) }}</p>
<a href="{{ rec_post.absolute_url }}" class="yourBtnClasses">read more</a>
</div>
{% endfor %}
</div>

 

best, 

Anton

Anton Bujanowski Signature