Related Posts on a CPT

Is it possible to get related sibling posts on a CPT? I’m using a single layout for my individual cpt posts. This posts uses a single custom category. I would like to create a looper that displays other posts from the current category. Is this possible?

Hello Sheri,

Thanks for writing in! Yes, it is possible to get the related custom posts. You can check this thread as a reference:

You can use the Query String Looper provider. Based on the thread, you can have this query string:
category_name ={{dc:term:slug}}&post_type=your_custom_post_type&posts_per_page=3&offset=0&ignore_sticky_posts=1&post__not_in%5B0%5D={{dc:post:id}}

You just need to change the your_custom_post_type with the exact custom post type name or slug to make it work.

Best Regards.

1 Like

Perfect! Thank you.

Hi Sheri,

You’re welcome! If you have any other concerns or clarifications regarding our theme features, feel free to open up a new thread.

Thank you.

I may have spoken too soon. It’s grabbing all posts from the post type. It is not limited to one category. I’m working in version 5.0.8

I looked at the output of {{dc:looper:debug_provider}}. Most of the keys have values that match what I specified in the query string, but I don’t see one to limit the category scope.

The [“category_name”] key just shows string(0) “”

What should I be checking to fix this?

Since my last post I fixed the issue with the category and it now shows up in the debug information. Even so, the results still aren’t limited to that category.

Hey Sheri,

Instead of category_name you might need to query the taxonomy like in this thread

Like in that thread:

Thanks.

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