Home Forums Front-end Issues Sort post by category


Sort post by category

  • Hi
    I use the ACF for a custom post type for displaying recipes. And I need some help with showing the posts. I have tried to use WP default category, ACF category, ACF taxonomy, ACF select an so on…

    What I’m trying to do is to sort my posts in the custom post type by recipe categories, like:
    Recipe 3…
    Recipe 6…

    I have succeeded with displaying the posts, but not sorted like above.

    And I don’t now how to solve this the best way.
    Any idea anyone?

    Regards Malin

  • Hi,
    I think I may have an idea on that one, you could create a category called
    “Recipes” in that category you would have te following child categories “RecipeCAT1, RecipeCAT2, RecipeCAT3” and so on…

    when you create a post you asign “Recipes” and “RecipeCAT1” as categories.

    then you could get all the “RecipeCAT” in an array with get_terms
    and inside a foreach loop put a wp_query that will get you the post from each RecipeCAT and display them one after the other.

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

The topic ‘Sort post by category’ is closed to new replies.