• Hello

    I have not been able to work something out, trying many different ways. I hope you can help.

    There is a post type: Wine
    Each wine has two associated taxonomies: Wine Type & Wine Region

    Wine Type:
    – Red
    – White
    – Rose

    Wine Region:
    – Italy
    — Toscana
    – Frace
    — Loire

    Example: Good Wine | Rose | Toscana

    Now, the out put layout should be:

    *** ROSE (wine type) ***
    Italy (region taxonomy parent)
    – Toscana (region taxonomy)
    — Good Wine (post)
    — Better Wine
    – Rome
    — Nice Wine
    France
    – Loire
    — French Wine 1
    — French Wine 2

    *** Red Wine ***
    Italy (region taxonomy parent)
    – Toscana (region taxonomy)
    — Good Red Wine (post)
    — Better Red Wine
    – Rome
    — Nice Red Wine
    France
    – Loire
    — French Red Wine 1
    — French Red Wine 2
    etc..

    1- I could not figure out how to use orderby taxonomy in a loop.
    2- It seems like nested [for] is not working if taxonomies are different. I have tried creating shortcodes and they do not work.
    3- I could not find out how to get the parent of an associated taxonomy. If a wine’s taxonomy is Toscana, how can I have Italy (the parent) as output?

    Any kind of help will be appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • 1. Where does the “Good Wine” comes from?

    Example: Good Wine | Rose | Toscana

    2. I could not figure out how to use orderby taxonomy in a loop.

    Do a FOR and then run the loop – then you can order the taxonomy first and the order the content based on a whatever.

    • This reply was modified 3 years, 12 months ago by polarracing.
    Thread Starter kamyarhu

    (@kamyarhu)

    Thank you for your response @polarracing

    1. Example: Good Wine (post) | Rose (taxonomy drink-category) | Toscana (taxonomy drink-region / second level)

    2. The reason this down’t work is that, the region FOR needs to be inside a drink category FOR, and it doesn’t return any value. It can be like:
    [for each=drink-category]
    [-for each=drink-region]
    but this doesn’t work. When FOR of one taxonomy is inside another on no value is returned.

    Maybe you could try this (had no chance to test):

    [loop type=WINE taxonomy=WINE TYPE] -> Limits the results to posts in WINE TYPE
      [for each=WINE TYPE] -> I assume there is only one per Post
        [each name] -> Gives you your headline "RED WINE"
      [/for]
      [for each=REGION empty=true]
        [each name] -> should give you the region-list "TOSCANY, ..."
      [/for]
    [/loop]
    Thread Starter kamyarhu

    (@kamyarhu)

    @polarracing thank you so much… I think your solution can work.
    I ended up adding the taxonomies as extra ACF fields to the post type, and then used them in the [LOOP] and somehow managed it. Thank you again

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Sorting according to two separate taxonomies’ is closed to new replies.