Forums

Need help with a nested loop using custom post type and taxonomies (2 posts)

  1. velocitykendal
    Member
    Posted 2 years ago #

    Hi,

    I'm having trouble from the off with what I'm trying to do so maybe someone here can set me on the right path?

    • I have a custom post type, 'artists'.
    • I have a custom taxonomy, 'genre'.
    • Posts within the 'artists' post type are being tagged under the genre taxonomy with things like 'house', 'techno', 'hip hop' etc.

    I would like to create a page that runs a nested loop, firstly outputting a list of genre tags that are in use within the 'artists' post type (omitting the tags that aren't associated to any posts yet). I would then secondly like nest another loop in each of these listed tags that outputs a list of artist posts using this tag and still within the 'artists' post type. I hope that makes sense?

    So far I've fallen at the first hurdle as seemingly I can only get a list of all the tags associated to all of the post retrieved. This inevitably results in duplication of some tags multiple times.

    Any help with this will be greatly appreciated.

    TIA

    VK

  2. velocitykendal
    Member
    Posted 2 years ago #

    Just to add to this...

    So what I'm trying to get is:

    • House
      • Post 1
      • Post 3
      • Post 12
    • Techno
      • Post 2
      • Post 7
      • Post 8
      • Post 10
    • Hip Hop
      • Post 4
      • Post 9

    The genre tags only get output if there's a published post using that tag.

    Any ideas anyone?

Topic Closed

This topic has been closed to new replies.

About this Topic