CMS Development

tjford
Member

Module that lists popular blog posts from a given topic

Hello,

I'd like to make a custom module that lists the 3 most popular blog posts from a given topic. Has anyone done something similar or know how?

Thanks!

Tyler

0 Upvotes
3 Replies 3
ZillaTeam
Participant

Module that lists popular blog posts from a given topic

Is there any function like blog_post_archive_url to get the URL of popular post listing page or is there any way to create a .absolute_url function for popular post listing page.

0 Upvotes
JagadishINB
Member | Platinum Partner
Member | Platinum Partner

Module that lists popular blog posts from a given topic

Hi @tjford,

 

Please try this below code,

{% set pop_posts = blog_popular_topic_posts('Your_Blog_ID', 'Your_Topic', 5) %}
{% for pop_post in pop_posts %}
<div class="post-title">{{ pop_post.name }}</div>
{% endfor %}

0 Upvotes
tjford
Member

Module that lists popular blog posts from a given topic

Thanks @JagadishINB - with a little bit of tweaking - I was able to get it to work with this:

 

{% set posts = blog_popular_posts ('default', 5) %}
{% for post in posts %}
{% if 'your topic' in post.topic_list|map('name') %}
<h3><a href="{{ post.absolute_url }}">{{ post.name }}</a></h3>
{% endif %}
{% endfor %}

 

Cheers!

Tyler

0 Upvotes