Hi! I’m building an aggregated listing page in HubSpot CMS where I pull posts from two different blogs using:
- case_posts = blog_recent_posts(case_studies_blog_id, 200)
- insight_posts = blog_recent_posts(insights_blog_id, 200)
Right now they render in two separate loops, so they are grouped by blog. I need them mixed together and sorted by publish date (newest first).
I’m running into HubL errors when trying to sort/merge, and I suspect it’s because I’m using the wrong date property on the post object in this context.
Questions:
- What is the correct property to use for the publish date on objects returned by blog_recent_posts()?
Is it post.publish_date, post.publishDate, post.published_at, post.created, or something else? - What type/format is that field (integer timestamp vs string date)?
- Is there a recommended HubL approach to merge and sort posts from two blogs by date?
If not, what’s the recommended client-side approach (e.g., adding a data-* attribute) without causing HubSpot template errors?
Extra info:
- Using a custom grid + JS filtering/pagination based on data-type and data-tags.
- I can add additional data-* attributes per post if needed.
Any guidance or examples would be appreciated.
{# debug: show available fields #}
<pre>{{ case_posts[0]|tojson }}</pre>