0

I am working on a Hubspot COS website and I need to be able to run custom queries on blog posts and display a list of those blog posts in a module on the home page and in the sidebar on the website.

Where do I start? I have tried using the RSS module, but it is not specific enough for my needs.

If you have any advise it would be much appreciated. Thanks!

Marc
  • 4,661
  • 3
  • 40
  • 62
  • Are topic-based RSS feeds specific enough?http://knowledge.hubspot.com/articles/kcs_article/cos-blog/how-do-i-find-the-rss-feed-for-a-specific-blog-topic ... If not, do you have a sample set of posts + query? – Kirk H Feb 19 '16 at 22:33

1 Answers1

3

I was able to use blog_recent_topic_posts() to solve this problem:

<div class="row-fluid">

{% set posts = blog_recent_topic_posts('3904474513', 'featured-resource', 3) %}
{% for post in posts %}
    {% set topics = post.topic_list %}

    <div class="span4 resource">
        <div class="resource-icon{% for topic in topics %} {{ topic.slug }}{% endfor %}"></div>
        <img src="{{ post.featured_image }}" alt="{{ post.name }}">
        <div class="resource-text">
            <p class="r-type">
            {% for topic in topics %}
                {% unless topic == 'featured resource' %}
                    {{ topic.name }} 
                {% endunless %}
            {% endfor %}    
            </p>
            <h3 class="r-title"><a href="{{ post.absolute_url }}">{{ post.name }}</a></h3>
        </div>
    </div>

{% endfor %}

</div>
Marc
  • 4,661
  • 3
  • 40
  • 62
  • hi Is there any way to add multiple tags?? – subindas pm Sep 29 '18 at 07:01
  • It looks like `blog_recent_topic_posts()` only accepts one topic within the argument so you would need to run a loop for each topic. Here is a tutorial from HubSpot about creating a related post section. There is a part at the bottom where they create a related post section that includes multiple topics which might be useful for you. https://designers.hubspot.com/tutorials/creating-a-related-post-section-with-hubl – Marc Oct 02 '18 at 16:16