CMS Development

Avery1
Member | Elite Partner
Member | Elite Partner

I need to display blog posts per category on specific pages

I have created a new blog named "Case Studies". I am assigning categories to the case studies. I need to display category pages that have custom content for each and the blog feed displayed in a grid/thumbnail layout. I have set up a page where the end user would select the category on the backend, but the blog posts will not display. I have used this, https://designers.hubspot.com/tutorials/creating-a-related-post-listing,  as a reference, but am having no luck. 

0 Upvotes
2 Replies 2
Kevin-C
Recognized Expert | Partner
Recognized Expert | Partner

I need to display blog posts per category on specific pages

Hey @Avery1 

 

Can you post a test page and the code you've tried? With that info we should be able to diagnose this issue.

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
Avery1
Member | Elite Partner
Member | Elite Partner

I need to display blog posts per category on specific pages

here is the code I have tried. I think the issue is I am trying to use a related posts code on an actual page, but it is not working on a blog post either.

 

<div class="row-fluid ">
    <div class="span12 widget-span widget-type-raw_jinja " style="" data-widget-type="raw_jinja" data-x="0" data-w="12">
    
     {% macro blog_post_formatter(post) %}
       <div class="span4">
         <div class="post-card {% for topic in post.topic_list %}{{ topic.slug }}{% if not loop.last %} {% endif %} {% endfor %} bh-ver">
           <div class="bh-hor">
             <a href="{{ post.absolute_url }}">
               <div class="ft-image" style="background: url('{{ post.featured_image }}') center no-repeat;">
               </div>
               <div class="content">
                 <h5>{{ post.name }}</h5>
                 <p>
                   {{ post.publish_date|datetimeformat('%B %e, %Y') }}
                 </p>
               </div>
             </a>
            </div>
           </div>
         </div>
       {% endmacro %}

       {% set post_tags = content.tagList|join(", ") %}
       {% related_blog_posts limit=3, tags="{{ post_tags }}" post_formatter="blog_post_formatter" %}

</div>
<!-- end of blog related section -->
0 Upvotes