<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Blog Listing Page Sort Functionality Not Working Properly in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Blog-Listing-Page-Sort-Functionality-Not-Working-Properly/m-p/984001#M39308</link>
    <description>&lt;P&gt;Thanks for your response&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/506314"&gt;@Gau&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately this workaround did not solve the problem. The blog posts were coming back in the exact same order as they did with the code that I had used.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 May 2024 17:05:48 GMT</pubDate>
    <dc:creator>omev</dc:creator>
    <dc:date>2024-05-29T17:05:48Z</dc:date>
    <item>
      <title>Blog Listing Page Sort Functionality Not Working Properly</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Blog-Listing-Page-Sort-Functionality-Not-Working-Properly/m-p/983572#M39299</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have built a Blog Listing Page which is expected to show 6 blog&amp;nbsp; tiles at a time on each page, sorted by the date they were each created. The issue I am having is that they are not coming back in the exact correct order. The order is close to being correct, but it is slightly mixed up.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have followed these steps:&lt;/P&gt;&lt;P&gt;1. I opened "Blog Settings", clicked on the "Templates" tab, and under "Number of posts per listing page" I set the number to 6. This is working as expected&lt;/P&gt;&lt;P&gt;2. In my code, I added the following to sort the blogs:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{% for content in contents|sort(False, False, 'created') %}
 {# The HTML for the tiles gets populated in the javascript #}
  &amp;lt;a
    href={{ content.absolute_url }}  
    class="tile" 
    data-blog-tile 
    data-createddate="{{ format_datetime(content.created, dateFormat) }}"
    data-featuredimage="{{ content.featured_image }}"
    data-taglist="{{ content.tag_list }}"
    data-title="{{ content.name }}"
    data-href="{{ content.absolute_url }}"
  /&amp;gt;
{% endfor %}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can validate that the blog posts are not coming up in the exact order by going to the Blog Posts page, and sorting them by Created Date. I can see that the first 5 I get in the response on the Listings Page are correct, but then the 6th one is out of order. On the second page, where I expect to get the next 6, the first 3 are in the correct order, and then the last 3 are mixed up.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Has anyone ever experienced this before? Any helps is greatly appreciated!&lt;BR /&gt;&lt;BR /&gt;*Update: I am noticing that the 6 blog posts that are showing up are actually the 6 most recently &lt;STRONG&gt;published&lt;/STRONG&gt;, and the code I have added to sort the blog posts is sorting those 6 blog posts by the &lt;STRONG&gt;created&lt;/STRONG&gt; date.&amp;nbsp;&amp;nbsp;What I am trying to achieve is to get the 6 most recently&amp;nbsp;&lt;STRONG&gt;created&lt;/STRONG&gt; as part of the original response. Does anyone know if this is possible?&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/92197"&gt;@albertsg&lt;/a&gt;&amp;nbsp;this is in line with what you mentioned about the original response being sorted by the&amp;nbsp;&lt;STRONG&gt;publish date.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 18:55:37 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Blog-Listing-Page-Sort-Functionality-Not-Working-Properly/m-p/983572#M39299</guid>
      <dc:creator>omev</dc:creator>
      <dc:date>2024-06-04T18:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: Blog Listing Page Sort Functionality Not Working Properly</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Blog-Listing-Page-Sort-Functionality-Not-Working-Properly/m-p/983631#M39301</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/701645"&gt;@omev&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the "blog_recent_posts" function to list blogs by their created date. Here is the &lt;A href="https://developers.hubspot.com/docs/cms/hubl/functions#blog-recent-posts" target="_blank" rel="noopener"&gt;doc&lt;/A&gt; if you wanna know more.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{{ blog_recent_posts("default", 5) }}
{% set rec_posts = blog_recent_posts("default", 5) %}
{% for rec_post in rec_posts %}
    &amp;lt;div class="post-title"&amp;gt;{{ rec_post.name }}&amp;lt;/div&amp;gt;
{% endfor %}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"I hope this will help you out. Please mark it as &lt;STRONG&gt;Solution Accepted and upvote&lt;/STRONG&gt; to help another Community member.&lt;BR /&gt;Thanks!"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 07:35:40 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Blog-Listing-Page-Sort-Functionality-Not-Working-Properly/m-p/983631#M39301</guid>
      <dc:creator>GRajput</dc:creator>
      <dc:date>2024-05-29T07:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: Blog Listing Page Sort Functionality Not Working Properly</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Blog-Listing-Page-Sort-Functionality-Not-Working-Properly/m-p/984001#M39308</link>
      <description>&lt;P&gt;Thanks for your response&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/506314"&gt;@Gau&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately this workaround did not solve the problem. The blog posts were coming back in the exact same order as they did with the code that I had used.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 17:05:48 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Blog-Listing-Page-Sort-Functionality-Not-Working-Properly/m-p/984001#M39308</guid>
      <dc:creator>omev</dc:creator>
      <dc:date>2024-05-29T17:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: Blog Listing Page Sort Functionality Not Working Properly</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Blog-Listing-Page-Sort-Functionality-Not-Working-Properly/m-p/985761#M39338</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/701645"&gt;@omev&lt;/a&gt;!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I believe blogs are ordered by &lt;STRONG&gt;Published Date&lt;/STRONG&gt; and not by Created Date.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You shouldn't need to use any filter for sorting, {{contents}} should include the blogs already ordered. Important to note that &lt;STRONG&gt;you can modify that order&lt;/STRONG&gt; by Unpublishing and Publishing again blog posts (you can publish them in a past date as well).&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The following code should be enough:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{% for content in contents %}
    &amp;lt;div class="post-item"&amp;gt;
        Post item markup that renders with each iteration.              
    &amp;lt;/div&amp;gt;
{% endfor %}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if you want to list your blogpost using a different date, then you will need a |sort filter, yes (altough I personally don't recommend this approach as it can get messy once the Blog content grows).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I recommend you to take a look at this page:&amp;nbsp;&lt;A href="https://developers.hubspot.com/docs/cms/building-blocks/templates/blog" target="_blank"&gt;https://developers.hubspot.com/docs/cms/building-blocks/templates/blog&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jun 2024 19:04:30 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Blog-Listing-Page-Sort-Functionality-Not-Working-Properly/m-p/985761#M39338</guid>
      <dc:creator>albertsg</dc:creator>
      <dc:date>2024-06-02T19:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: Blog Listing Page Sort Functionality Not Working Properly</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Blog-Listing-Page-Sort-Functionality-Not-Working-Properly/m-p/986891#M39354</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/92197"&gt;@albertsg&lt;/a&gt;&amp;nbsp;, thank you for your response!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am actually looking to sort the blogs by their&amp;nbsp;&lt;STRONG&gt;Created Date&lt;/STRONG&gt;, and not by the&amp;nbsp;&lt;STRONG&gt;Publish Date&lt;/STRONG&gt;. That is why I have implemented the sort filter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am curious what you mean by this comment:&lt;/P&gt;&lt;P&gt;"&lt;SPAN&gt;(altough I personally don't recommend this approach as it can get messy once the Blog content grows)." - What kind of "messiness" have you experienced in the past? Is having blog posts return in the incorrect order something that you have seen previously?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 17:57:40 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Blog-Listing-Page-Sort-Functionality-Not-Working-Properly/m-p/986891#M39354</guid>
      <dc:creator>omev</dc:creator>
      <dc:date>2024-06-04T17:57:40Z</dc:date>
    </item>
    <item>
      <title>Re: Blog Listing Page Sort Functionality Not Working Properly</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Blog-Listing-Page-Sort-Functionality-Not-Working-Properly/m-p/986974#M39355</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/701645"&gt;@omev&lt;/a&gt;!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me tell you more about my experience with blog listing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In one of the projects I was working on, I was requested to create a "different" listing for the blog, not by created date but by other factors.&amp;nbsp;&lt;BR /&gt;For the initial X articles it was not a problem, but when the number of articles started to grow, I was facing quite some critical challenges:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- HubSpot returns the articles inside the {{contents}} variable, which is sorted by published date. You can sort that list out (sorting can be challenging as you are experiencing - I've had some long conversations with HubSpot support in the past regarding this topic) but things will start to get complicated when you have more than X articles and you need to start doing pagination. You will have to create your own custom pagination behaviour, which again can be tricky as you have to not just order {{contents}} but also make sure you are seeing the correct articles for the pagination page you are in.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- All this sorting comes with a performance impact that might affect the user experience on your site, conversion rates, etc.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- I wrote a bit about this issue here, maybe it helps you see other possible issues you might encounter:&amp;nbsp;&lt;A href="https://community.hubspot.com/t5/HubSpot-Ideas/Blog-listing-why-there-is-a-limit/idi-p/410514" target="_blank"&gt;https://community.hubspot.com/t5/HubSpot-Ideas/Blog-listing-why-there-is-a-limit/idi-p/410514&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Because of this, I encourage you to stick with HubSpot's "default" functionality. You can always Unpublish and Publish again articles in a past date and sort them in the order you want, but of course that's just my suggestion&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 20:19:36 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Blog-Listing-Page-Sort-Functionality-Not-Working-Properly/m-p/986974#M39355</guid>
      <dc:creator>albertsg</dc:creator>
      <dc:date>2024-06-04T20:19:36Z</dc:date>
    </item>
  </channel>
</rss>

