Support

Account

Home Forums ACF PRO show posts from custom post type with specific post object

Helping

show posts from custom post type with specific post object

  • Hi guys.

    This is a tricky one to explain but hopefully I can make sense below, fingers crossed someone understands and knows how to help!

    I’ve created a custom post type called “team” where I can create new team members as posts, all good.

    I also have a standard post category called recipes where I have a post object field called “author”, this is set to filter by post type “team” so that I can select the author of the recipe from the team custom post type, all good.

    Now, and this is the bit I’m trying to figure out…

    I’d like to be able to show the recipes that team member is linked to in the “author” post type. These will be shown in the “team” single post page, which I have a custom template for.

    I would like it to be as automated as possible so that when I add a new recipe and choose the “author” from the team members, the feed is automatically updated with all their recipes.

    in short, I need some functionality that says, if team = a, show all posts from recipes category that have a post object of a.

    Hope that makes sense and someone can help me figure it out.

  • You are on the team single post and you are attempting to show posts in a category that are related to this post through a category. Not easy, and I cannot really do all the code for you.

    CPT (team) => Categories (team selected here) => posts in categories

    You need to do a reverse relationship query on the categories (taxonomy) to get a list of categories where the team is selected, very similar to this https://www.advancedcustomfields.com/resources/querying-relationship-fields/.

    Then you need to do another query on for the posts that you want to show based on the categories returned in step 1.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘show posts from custom post type with specific post object’ is closed to new replies.