CMS Development

twspri
Member

Setting up a second blog that pulls in posts based on blog tags?

Hi, I am trying to set up a second blog on my site -- essentially just a podcast section -- but I want to populate it with posts from my primary blog, pulling in any posts that are tagged as  "podcast" automatically. Is this possible?

 

Thanks!

 

Tim

0 Upvotes
2 Replies 2
John
Top Contributor | Platinum Partner
Top Contributor | Platinum Partner

Setting up a second blog that pulls in posts based on blog tags?

{% set blog_one_posts = blog_recent_posts('default', limit=5) %} 
{# sets a variable for a the 5 most recent posts of my default COS blog #}

{% set blog_two_posts = blog_recent_posts('2nd_blog_id', limit=5, 'specific-tag') %}  
{# sets a variable for a the 5 most recent posts of 2nd blog id. You can find the blog id in the URL of the blog dashboard for a particular blog. Also grabs the tag name specific-tag #}

{% set all_posts = (blog_one_posts + blog_two_posts) | sort(true, false, 'publish_date')  %} 
{# combines the two variables into a single variable and sorts them by publish date. Please note the sort filter requires all three parameters #}

{% for post in all_posts %}
    {# post.content markup goes here #}
{% endfor %}

 the blog_recent_posts function has a limit of 200 posts



I like kudos almost as much as cake – a close second.

0 Upvotes
sking1
Contributor

Setting up a second blog that pulls in posts based on blog tags?

@John - I have a similar project. I noticed when you're specifying tags and the number of posts you didn't use quotes. Can you check my syntax? I'm attempting to dynamically add the tags I want to use (I didn't include the filter I am using, which is working).

 

{% set blog_one_posts = related_blog_posts('1111111111', tags="{{ topic.name }}{% if not loop.last %},{% endif %}", limit="5") %} <!-- video --> 
{% set blog_two_posts = related_blog_posts('2222222222', tags="{{ topic.name }}{% if not loop.last %},{% endif %}", limit="5") %} <!-- article -->
{% set blog_three_posts = related_blog_posts('3333333333', tags="{{ topic.name }}{% if not loop.last %},{% endif %}", limit="5") %} <!-- infographic -->
{% set blog_four_posts = related_blog_posts('4444444444', tags="{{ topic.name }}{% if not loop.last %},{% endif %}", limit="5") %} <!-- report -->
             
{% set all_posts = (blog_one_posts + blog_two_posts + blog_three_posts + blog_four_posts) %} 

Also, do you have a workaround for the 200 blog post cap?

 

 

 

0 Upvotes