CMS Development

LaurenO
Participant

Using HubL code for multiple topics in RSS feed

Hi all, 

 

I'm trying to figure out how to build an RSS feed using the HubL coding so I can pull in two topics from my blog. 

 

1. Main topic > Parts

2.  Secondary topic > C-arm 

 

Therefore, it will pull in the PARTS articles and from the 'parts' articles, it will pull in anything labeled under the topic C-ARM. 

 

Is this possible? If so, how is it possible?

 

Thank you! 

0 Upvotes
2 Replies 2
Stephanie-OG
Key Advisor

Using HubL code for multiple topics in RSS feed

Hey Lauren, 

 

You can pull posts from a topic using blog_recent_topic_posts, so the below would get the posts from topic1 and topic2 respectively:

 

{% set topic1_posts = blog_recent_topic_posts('default', 'topic1', 5) %}
{% set topic2_posts = blog_recent_topic_posts('default', 'topic2', 5) %}

You should then be able to combine the two lists: 

 

{% set combined_topics = topic1_posts + topic2_posts %}

And can work with the combined_topics list, e.g.: 

 

{% for post in combined_topics %}
  <div class="post-title">{{ post.name }}</div>
{% endfor %}

 

EDIT: this post has similar code to the above but with more detail (and the sort filter).

 

I hope that helps!

 


Stephanie O'Gay GarciaHubSpot Design / Development

Website | Contact

 

If this helped, please mark it as the solution to your question, thanks!

0 Upvotes
LaurenO
Participant

Using HubL code for multiple topics in RSS feed

Thank you, Stephanie. You answered what I asked, but I didn't make my original question very clear.

 

It makes sense that you can bring in two different topics of blog posts. Now, can it go one step farther?

 

For instance

Step 1:  Bring all blogs relating to the 'Imaging Equipment Parts' topic

Step 2: Put another filter on step 1 = Filter the 'Imaging Equipment Parts' topic on another topic, 'C-Arms'. 

 

Therefore, the RSS feed will have only 1 listing - only blog posts that have both 'Imaging Equipment Parts' and 'C-Arms' in the topics tag. 

 

Is that possible? 

 

0 Upvotes