WordPress.org

Ready to get started?Download WordPress

Forums

How to group by taxonomy term (3 posts)

  1. gleenk
    Member
    Posted 2 years ago #

    This is the situation:

    I've got a custom post type called Disc.
    This Post Type has 1 taxonomy called Genre.
    This taxonomy has 2 terms: Rock and Pop.
    Rock has got a sub-term called Hard Rock.

    I want to show into archive page (or taxonomy page) a list of disc "grouped" by term. I don't want to put manually the name of taxonomy or term into tpl. It should be dinamic. So, for example:

    ROCK
    ACDC Album blabla
    IRON MAIDEN Album blabla

    POP
    AVRIL LAVIGNE Album blabla
    MILEY CYRUS Album blabla

    And I want to show both the title and the album. The ONLY way i found to do it is using a complex JOIN query. But I don't want to do this practise anymore. I would like to do this using CORE WordPress functionalities. Is it possible? In Drupal I should have done this using views and "grouped by taxonomy" option. Is there this "equivalent"? Thanks in advance to all

  2. dizmarkie
    Member
    Posted 2 years ago #

    I too am looking for this exact thing. I was able to find a way to list all the terms and related posts but prefer the method of just showing the terms and posts for the given page the user is on.

    if the user decides to add more terms the page would show the new term and related post without having to manually write queries on a per term basis.

  3. Rafael Wahasugui
    Member
    Posted 1 year ago #

    Hello, I'm working with default post default category and a custom taxonomy.

    Try to setup the following loop with your configs:

    http://pastebin.com/AmJp89xU

    :]

Topic Closed

This topic has been closed to new replies.

About this Topic