# Creating a custom blog listing

**URL:** <https://community.hubspot.com/t/creating-a-custom-blog-listing/44999>\
**Category:** CMS Development\
**Created:** [October 7, 2021, 9:26am UTC](https://community.hubspot.com/t/creating-a-custom-blog-listing/44999 "2021-10-07T09:26:38Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![DM2](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dm2/32/39641_2.png) [@DM2](https://community.hubspot.com/u/DM2)\
**Post date:** [October 7, 2021, 9:26am UTC](https://community.hubspot.com/t/creating-a-custom-blog-listing/44999/1 "2021-10-07T09:26:38Z")

</div>

hi there

I want to create a blog listing that goes like this (row by row):

Article 1 - ‘Feature Pick’ tagged Post.

Articles 2,3,4 - 3 Next most recent articles.

CTA.

All other Articles .

I am nearly there using this:

```lia-code-sample
{% set rec_posts = blog_recent_posts('default', 99) %}

	{% for post in rec_posts %}
		{% if 'Editors Pick' in post.topic_list|map('name') %}

			// Article 1 - 'Feature Pick' tagged Post

		{% endif %}
	{% endfor %}

 {% for post in rec_posts %}
		{% if loop.index in range(1,4) %}
 	{% if 'Editors Pick' not in post.topic_list|map('name') %}

 	// Articles 2,3,4 - Next most recent articles

			{% endif %}
		{% endif %}
	{% endfor %}

			CTA.

 {% for post in rec_posts %}
		{% if loop.index in range(4,99) %}
 	{% if 'Editors Pick' not in post.topic_list|map('name') %}

 	// All other Articles

			{% endif %}
		{% endif %}
	{% endfor %}

```

But am finding that becuase my ‘Feature Pick’ is techincally within the range (1,4) I am only getting 2 articles on that row. I could adjust it to range(1,5) but as soon as the article becomes older that system will break.

I am sure there is a better way of doing this if anyone could help I would be grateful.

Thank you!

---

<div class="post-metadata">

**Author:** ![erod](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/erod/32/99705_2.png) [@erod](https://community.hubspot.com/u/erod)\
**Post date:** [October 7, 2021, 5:27pm UTC](https://community.hubspot.com/t/creating-a-custom-blog-listing/44999/2 "2021-10-07T17:27:32Z")

</div>

Hi DM2,

You need to do something like this:

```lia-code-sample
{# First loop: featured posts #}
 {% for content in contents %}
 {% for topic in content.topic_list %}
 {% if topic.name == 'featured' %}
 {# Add your featured post markup here #}
 {% endif %}
 {% endfor %}
{% endfor %}

{# Second loop: all other posts #}
{% for content in contents %}
 {% for topic in content.topic_list %}
 {% if topic.name != 'featured' %}
 {# Add the markup for the rest of your posts here #}
 {% endif %}
 {% endfor %}
{% endfor %}

```

---

<div class="post-metadata">

**Author:** ![DM2](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dm2/32/39641_2.png) [@DM2](https://community.hubspot.com/u/DM2)\
**Post date:** [October 8, 2021, 7:39am UTC](https://community.hubspot.com/t/creating-a-custom-blog-listing/44999/3 "2021-10-08T07:39:06Z")

</div>

Thanks @erod but I actually need to split the artticles in to three sections:

- **Article 1 - ‘Feature Pick’ tagged Post.**
- **Articles 2,3,4 - 3 Next most recent articles.**
- CTA (and other bits and pieces)
- **All other Articles .**

Is there a way of doing that with your solution above?

---

<div class="post-metadata">

**Author:** ![erod](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/erod/32/99705_2.png) [@erod](https://community.hubspot.com/u/erod)\
**Post date:** [October 8, 2021, 5:42pm UTC](https://community.hubspot.com/t/creating-a-custom-blog-listing/44999/4 "2021-10-08T17:42:42Z")

</div>

Try something like this. Be sure to set the range and don’t forget that tags are case sensitive.

```lia-code-sample
{# First loop: featured posts #}
 {% for content in contents %}
 {% for topic in content.topic_list %}
 {% if topic.name == 'Featured' %}
 {# Add your featured post markup here #}
 {% endif %}
 {% endfor %}
 {% endfor %}

{# CTA GOES HERE #}

{% for content in contents %}
{% if loop.index in range(X,X) %}
 {% for topic in content.topic_list %}
 {% if topic.name != 'Featured' %}
 {# Add your featured post markup here #}
 {% endif %}
 {% endfor %}
 {% endfor %}

{# The rest of the posts #}

{% for content in contents %}
 {% if loop.index in range(X,99) %}
 {% for topic in content.topic_list %}
 {% if topic.name != 'Featured' %}
 {# Add your markup here #}
 {% endif %}
 {% endfor %}
 {% endif %}
{% endfor %}

```

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 8, 2021, 1:05pm UTC](https://community.hubspot.com/t/creating-a-custom-blog-listing/44999/5 "2021-10-08T13:05:36Z")

</div>

Hi @DM2 ,  
You can use this Hubspot blog listing module and create the blog listing customization according to your need. [Edit blog listing pages](https://knowledge.hubspot.com/cos-blog/how-do-i-list-my-most-popular-posts-on-my-blog)

Hope this helps!

If we were able to answer your query, kindly help the community by marking it as a solution.  
Thanks and Regards.

---

<div class="post-metadata">

**Author:** ![DM2](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dm2/32/39641_2.png) [@DM2](https://community.hubspot.com/u/DM2)\
**Post date:** [October 8, 2021, 1:17pm UTC](https://community.hubspot.com/t/creating-a-custom-blog-listing/44999/6 "2021-10-08T13:17:56Z")

</div>

Thanks [@webdew](https://community.hubspot.com/t5/user/viewprofilepage/user-id/131510) but unfortunately that doesn’t help my particular scenario.

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [October 8, 2021, 2:40pm UTC](https://community.hubspot.com/t/creating-a-custom-blog-listing/44999/7 "2021-10-08T14:40:58Z")

</div>

I feel like @Anton just had an answer for this recently. @Anton , remember what post that was?

---

<div class="post-metadata">

**Author:** ![JSmith49](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jsmith49/32/48165_2.png) [@JSmith49](https://community.hubspot.com/u/JSmith49)\
**Post date:** [October 11, 2021, 11:17am UTC](https://community.hubspot.com/t/creating-a-custom-blog-listing/44999/8 "2021-10-11T11:17:10Z")

</div>

Hello @DM2 ,

You can utilize this Hubspot blog posting module and

[make](https://www.sydneyfoodco.com/)

the blog posting customization as per your need. [Edit blog listing pages](https://knowledge.hubspot.com/cos-blog/how-do-i-list-my-most-popular-posts-on-my-blog)

Trust this makes a difference!

In case we had the option to answer your inquiry, compassionately help the local area by checking it as an answer.

Much obliged and Regards.

---

<div class="post-metadata">

**Author:** ![DM2](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dm2/32/39641_2.png) [@DM2](https://community.hubspot.com/u/DM2)\
**Post date:** [October 11, 2021, 11:59am UTC](https://community.hubspot.com/t/creating-a-custom-blog-listing/44999/9 "2021-10-11T11:59:24Z")

</div>

Thank you for your continued support @erod. I guess this comes down to whether, in the statement below, a ‘Featured’ article would be included within the **count** of a loop.index range even though we’re not displaying it. I want to make sure I return 3 articles at this point. If the article is included I would only return 2?

```lia-code-sample
{% for content in contents %}
{% if loop.index in range(1,4) %}
 {% for topic in content.topic_list %}
 {% if topic.name != 'Featured' %}
 {# Add your featured post markup here #}
 {% endif %}
 {% endfor %}
 {% endfor %}

```

---

<div class="post-metadata">

**Author:** ![erod](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/erod/32/99705_2.png) [@erod](https://community.hubspot.com/u/erod)\
**Post date:** [October 11, 2021, 7:55pm UTC](https://community.hubspot.com/t/creating-a-custom-blog-listing/44999/10 "2021-10-11T19:55:46Z")

</div>

I tested it and it works. All you have to do is play around with the ranges. So, instead of 1,4 you might try 2,5 and then 6,99 for the rest. @DM2
