CMS Development

radar
Contributor

Combine two topics into one list, outside blog

SOLVE

Is it possible to combine two topics into one list? When I say combine, I mean only show posts where the given set of topics are present at the same time. 

 

For example:

 

 

{% set topic1 = blog_recent_topic_posts('default', 'topic1_name', limit=25) %} 
{% set topic2 = blog_recent_topic_posts('default', 'topic2_name', limit=25) %}

{% set all_posts = (topic1 + topic2) | sort(true, false, 'publish_date') %}

{% for post in all_posts %}
{# markup #}
{% endfor %}

 

 

If working as intended this would yield a list of results where only topic1 and topic2 are present on the same post.

 

The error I've had is the resulting list shows all posts with topic1 and then a duplicate post with topic1 + topic2.

 

Any thoughts?

 

0 Upvotes
1 Accepted solution
radar
Solution
Contributor

Combine two topics into one list, outside blog

SOLVE

That documentation is helpful, not quite what I was looking for though. Essentially I was going to use HubL to display a series of posts based on a specific combination of tags only if they were both mutually present at the same time.

 

Said another way, instead of getting all posts tagged with either topic1 and or topic2, only show posts when topic1 and topic2 exist together. 


I ended up using some filtering, post IDs and a drop down to select specific posts to show where relevant. This was for a directory listing, not a traditional blog if curious.

View solution in original post

0 Upvotes
3 Replies 3
jennysowyrda
Community Manager
Community Manager

Combine two topics into one list, outside blog

SOLVE

Hi @radar,

 

Are you still experiencing this issue? 

 

Have you taken a look at the HubL docs and tuitorials? They may be a good starting point to take a look at. I wanted to share this tuitorial for reference (see more along the left hand side).

 

If you're still having issues after taking a look at those, please let us know. 

 

Thank you,

Jenny

0 Upvotes
radar
Solution
Contributor

Combine two topics into one list, outside blog

SOLVE

That documentation is helpful, not quite what I was looking for though. Essentially I was going to use HubL to display a series of posts based on a specific combination of tags only if they were both mutually present at the same time.

 

Said another way, instead of getting all posts tagged with either topic1 and or topic2, only show posts when topic1 and topic2 exist together. 


I ended up using some filtering, post IDs and a drop down to select specific posts to show where relevant. This was for a directory listing, not a traditional blog if curious.

0 Upvotes
jennysowyrda
Community Manager
Community Manager

Combine two topics into one list, outside blog

SOLVE

Thank you for sharing @radar

0 Upvotes