Layout Single: Show 2 posts from the same category

Dear Pro Team,

I’m trying to build a “show similar posts” module. How should I set the looper provider up to achieve this goal? For instance If the main post entry belongs to the category A, it should automatically generate 2 teaser post entries from the same category “A”

Thanks in advance.

Hey @burkiburak,

If you only assign each post 1 category, it is possible. In fact, it’s possible with multiple categories but in this case, the related posts are duplicated in case they’re assign to multiple categories too.

You will want to use the Current Post Terms as your Looper Provider

image

Then, you let an element consume the categories then an element inside it to be a Looper Provider for the actual posts.

For example, you set the Section as the Current Post Terms provider. You set the Row inside it to be a consumer. The Column within the Row should be a Looper Provider with the following setup. You can also set the column directly as a consumer.

image

category_name={{dc:term:name}}

image

If your category setup is complex or you’re using multiple categories per post, regretfully, the Looper has no setup for that yet.

Hope that helps.

hey @christian,

that worked out perfectly. Thanks a lot.

You’re welcome!
We’re glad @Christian’s solution works out for you.

another question to this topic. How would I block so that the same blog entry won’t appear in the “related articles” block?

Hi @burkiburak,

It depends on how you are showing the related posts. If you are using the Looper provide, you can add the {{dc:looper:field key=“id”}} is not {{dc:post:id}} which will skip the current post id to be shown.

Hope it helps.
Thanks

Hi,

Unfortunately, I couldn’t get it done. Mine right now looks like that:

In the POSTS row (Screenshot 1), I set a looper provider with:
Current Post Terms: Tags (Screenshot 2)

and above that in the post element (Screenshot 3)
Setup: {{dc:looper:field key=“id”}} is not {{dc:post:id}}
Looper Provider: Query String, tag_name={{dc:term:name}}

What am I doing wrong? I just want two related articles with the same tag show up without showing the same article above.

Thanks.Screenshot1

Hi @burkiburak,

Would you mind sharing your admin credentials so that we can check your settings properly? To do that, please give us the following information in a Secure Note.

  • WordPress Login URL
  • Admin level username and password

You can find the Secure Note button at the bottom of your posts.

Thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.