<?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 Recent Posts + Featured Post on Top in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Blog-Recent-Posts-Featured-Post-on-Top/m-p/775285#M33516</link>
    <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Wed, 29 Mar 2023 02:29:59 GMT</pubDate>
    <dc:creator>GWilkinson</dc:creator>
    <dc:date>2023-03-29T02:29:59Z</dc:date>
    <item>
      <title>Blog Recent Posts + Featured Post on Top</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Blog-Recent-Posts-Featured-Post-on-Top/m-p/774740#M33511</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to display a blog listing where the post tagged "Featured" is always listed first and then the rest of the posts are underneath.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what I want to do is something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{% set featured_posts = blog_tags('default', 'Featured', 1) %}
{% set recent_posts_limit = 5 %}
{% set excluded_post_id = 0 %}

{% if featured_posts.posts|length %}
  {% set excluded_post_id = featured_posts.posts[0].id %}
  {% set recent_posts = blog_recent_posts('default', recent_posts_limit - 1, exclude_ids=excluded_post_id) %}
{% else %}
  {% set recent_posts = blog_recent_posts('default', recent_posts_limit) %}
{% endif %}

&amp;lt;div class="recent-posts"&amp;gt;
  {% if featured_posts.posts|length %}
    {% for post in featured_posts.posts %}
      &amp;lt;div class="featured-post"&amp;gt;
        &amp;lt;h3&amp;gt;&amp;lt;a href="{{ post.absolute_url }}"&amp;gt;{{ post.name }}&amp;lt;/a&amp;gt;&amp;lt;/h3&amp;gt;
        &amp;lt;p&amp;gt;{{ post.post_summary }}&amp;lt;/p&amp;gt;
        &amp;lt;span&amp;gt;Posted on {{ post.publish_date|datetimeformat('%Y-%m-%d') }}&amp;lt;/span&amp;gt;
      &amp;lt;/div&amp;gt;
    {% endfor %}
  {% endif %}

  {% for post in recent_posts.posts %}
    &amp;lt;div class="recent-post"&amp;gt;
      &amp;lt;h3&amp;gt;&amp;lt;a href="{{ post.absolute_url }}"&amp;gt;{{ post.name }}&amp;lt;/a&amp;gt;&amp;lt;/h3&amp;gt;
    &amp;lt;/div&amp;gt;
  {% endfor %}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But there is no exclude_ids. Ive seen a few examples with two loops but im not sure how to explicitly exclude a tag. I tried topics but am not using a module for this so I dont think that was working for me either.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2023 03:44:53 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Blog-Recent-Posts-Featured-Post-on-Top/m-p/774740#M33511</guid>
      <dc:creator>GWilkinson</dc:creator>
      <dc:date>2023-03-28T03:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: Blog Recent Posts + Featured Post on Top</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Blog-Recent-Posts-Featured-Post-on-Top/m-p/775095#M33512</link>
      <description>&lt;P&gt;Hey,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/544245"&gt;@GWilkinson&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt; I moved this over to our CMS developer community. I'd also like to invite some of our community members to the conversation —&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/146956"&gt;@BarryGrennan&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/193060"&gt;@JBeatty&lt;/a&gt;, do&amp;nbsp;you have any tips you can share with&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/544245"&gt;@GWilkinson&lt;/a&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much for taking a look! — Jaycee&lt;/P&gt;</description>
      <pubDate>Tue, 28 Mar 2023 18:24:16 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Blog-Recent-Posts-Featured-Post-on-Top/m-p/775095#M33512</guid>
      <dc:creator>Jaycee_Lewis</dc:creator>
      <dc:date>2023-03-28T18:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: Blog Recent Posts + Featured Post on Top</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Blog-Recent-Posts-Featured-Post-on-Top/m-p/775285#M33516</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 02:29:59 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Blog-Recent-Posts-Featured-Post-on-Top/m-p/775285#M33516</guid>
      <dc:creator>GWilkinson</dc:creator>
      <dc:date>2023-03-29T02:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: Blog Recent Posts + Featured Post on Top</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Blog-Recent-Posts-Featured-Post-on-Top/m-p/775751#M33525</link>
      <description>&lt;P&gt;This should work:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{% set featured_posts = blog_recent_tag_posts("default", "featured", 1) %} {#featured is lowercase here as it's the slug #} {# also note we're using blog_recent_tag_posts to get the posts not blog_tags #}

{% set normal_recent_posts = blog_recent_posts('default', 5) %}

{% set featured_post_id = featured_posts[0].id %}

{# we want to work out if the featured post would show in the normal 5 recent posts, so we create an array of their ids #}
{% set post_array = [] %}
 {% for post in normal_recent_posts %}
      {% do post_array.append(post.id) %}
{% endfor %}

{# if the featured post is in the standard 5 we're going to add an extra post (6 total) so we can hide the featured in the loop #}
{% if post_array is containing featured_post_id %}
{% set displayed_recent_posts = blog_recent_posts('default', 6) %}
{% else %}
{% set displayed_recent_posts = blog_recent_posts('default', 5) %}
{% endif %}

FEATURED POSTS

 {% for post in featured_posts %}
 &amp;lt;div class="recent-post"&amp;gt;
      &amp;lt;h3&amp;gt;&amp;lt;a href="{{ post.absolute_url }}"&amp;gt;{{ post.name }}&amp;lt;/a&amp;gt;&amp;lt;/h3&amp;gt;
    &amp;lt;/div&amp;gt;
  {% endfor %}

NORMAL POSTS
  {% for post in displayed_recent_posts %}
{% unless post.id == featured_post_id %}
    &amp;lt;div class="recent-post"&amp;gt;
      &amp;lt;h3&amp;gt;&amp;lt;a href="{{ post.absolute_url }}"&amp;gt;{{ post.name }}&amp;lt;/a&amp;gt;&amp;lt;/h3&amp;gt;
    &amp;lt;/div&amp;gt;
{% endunless %}
  {% endfor %}&lt;/LI-CODE&gt;&lt;HR /&gt;
&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="profile2022a" style="width: 100px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/71500iE96AB1F9E9E277B9/image-size/small?v=v2&amp;amp;px=200" role="button" title="profile2022a" alt="profile2022a" /&gt;&lt;/span&gt;&lt;STRONG&gt;&lt;FONT size="5"&gt;Barry Grennan&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;A href="https://www.seoanseo.ca?utm_source=HubSpotCommunity" target="_blank" rel="nofollow noopener noreferrer"&gt;Freelance HubSpot CMS Developer&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.seoanseo.ca?utm_source=HubSpotCommunity" target="_blank" rel="nofollow noopener noreferrer"&gt;Website&lt;/A&gt; | &lt;A href="https://www.seoanseo.ca/#contact?utm_source=HubSpotCommunity" target="_blank" rel="nofollow noopener noreferrer"&gt;Contact&lt;/A&gt; | &lt;A href="https://www.linkedin.com/in/barrygrennan" target="_blank" rel="nofollow noopener noreferrer"&gt;LinkedIn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2023 18:02:43 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Blog-Recent-Posts-Featured-Post-on-Top/m-p/775751#M33525</guid>
      <dc:creator>BarryGrennan</dc:creator>
      <dc:date>2023-03-29T18:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Blog Recent Posts + Featured Post on Top</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Blog-Recent-Posts-Featured-Post-on-Top/m-p/775917#M33534</link>
      <description>&lt;P&gt;Thank you! Worked perfectly&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 02:43:44 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Blog-Recent-Posts-Featured-Post-on-Top/m-p/775917#M33534</guid>
      <dc:creator>GWilkinson</dc:creator>
      <dc:date>2023-03-30T02:43:44Z</dc:date>
    </item>
  </channel>
</rss>

