CMS Development

MKTG_Guy
Member | Partner
Member | Partner

Sort order for blog tag search

Is it possible to display blog posts searched by tag as a first-to-last posted date? If you click on a blog tag that has multiple posts, they show by the last post to the first post. I'm looking to link a blog series that we did and hoping that they can be displayed by the first post to the last post since the content builds from the original post. 

 

Thanks!

0 Upvotes
2 Replies 2
jennysowyrda
Community Manager
Community Manager

Sort order for blog tag search

Hey @MKTG_Guy,

 

Can you share the current template you're working with and a link to the page? 

 

@tjoyce or @AJLaPorte_diagr do you have any insight into how this could be accomplished? 

 

Thanks,
Jenny

0 Upvotes
AJLaPorte_diagr
Key Advisor

Sort order for blog tag search

@MKTG_Guy

 

You could try to use the reverse filter (https://designers.hubspot.com/docs/hubl/hubl-supported-filters#reverse) on your call to the topics. For example:

 

{# this will show top 5 recent posts from HubSpot tag with latest post first#}
{{ blog_recent_topic_posts('default', 'hubspot', 5 ) }}

{# this will grab those same posts and put them in variable #}
{% set topic_posts = blog_recent_topic_posts('default', 'hubspot', 5) %}

{# using 'reverse' filter, it will output them in reverse order [first post to latest post] #}
{% for topic_post in topic_posts|reverse %}
    <div class="post-title">{{ topic_post.name }}</div>
{% endfor %}

Hopefully, this helps. I just did a quick test in a custom module and it appears to work as intended. 

 

Likewise, you can always look into creating a custom module for an "In this Series" type widget that would list out all the posts in there. You could always make use of the related blog posts module and the override for adding your own posts based on id to the widget with some kind of text fields. Just an alternative idea. 

 

Let me know if you have any additional questions and sorry for the delay in response.

-AJ

 

----------------------------------------------------

AJ LaPorte
www.wsol.com