CMS Development

InciteJoe
Contributor | Gold Partner
Contributor | Gold Partner

Including limited topics on blog listing

Hello,

 

I am working on a blog listing that only includes three topics to begin with, it works using the code below but this breaks the /tag/ pages if I go to a tag page of a topic that isn't included in the below. I tried to add an IF statement for tags to change the query back to content in contents but can't get it to work.

 

{% set topic_posts = blog_recent_topic_posts(59843484546, ['upcoming-events', 'physical-event','webinar']) %}

{% for content in topic_posts %}

 

Any ideas? 

Thanks

0 Upvotes
1 Reply 1
Brownstephen101
Top Contributor | Elite Partner
Top Contributor | Elite Partner

Including limited topics on blog listing

Hello @InciteJoe ,

You could set your topics in a conditional statement based on the url of the page. Something like this:

 

{% if 'tag' in content.absolute_url %}
{% set tags = '' %}
{% else %}
{% set tags = ['upcoming-events', 'physical-event','webinar'] %}
{% endif %}

{% set topic_posts = blog_recent_topic_posts(59843484546, tags) %}

{% for content in topic_posts %}

 


Note: this code is not tested, so it might need a tweak or two.

Hope this helps