• Resolved t.yme1111

    (@tyme1111)


    Any clever way to group results by category?

    Use case: essentially a site map. Query filtered by 1 category to limit result set, but would like to then group those many results by another category for better structured viewing. Using display type Fields. Only group by option is Post Title.

    I would expect to be able to achieve that (in part) by adding field taxonomy:category (and excluding from display). Then selecting that taxonomy:category as the Group By option. However, I cannot add a field taxonomy — not among the options listed for Fields, as it is with Filters, in any case.

    (I tested by adding field Post Parent, but it was not then an option under Group By.)

    https://wordpress.org/plugins/query-wrangler/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jonathan Daggerhart

    (@daggerhart)

    If both terms (the one you want to filter by, and the one you want to group by) are part of the same taxonomy (category), then I don’t think there is an easy way to do this through the UI alone.

    The problem is that there is no existing (core) way to get just 1 specific category for a post during a loop. You can get all the terms using something like the_category(), but you can’t get just one, nor exclude any.

    If the data you wanted to group by was part of a different taxonomy, or if one of these things was metadata, it would be a bit easier.

    Thread Starter t.yme1111

    (@tyme1111)

    Both would be from the WP core Category taxonomy. But different “vocabularies”.

    So, one is from (parent) Stakeholder — used to filter.

    The other term that I’d like to group the results by is Topic (parent).

    It would be fine for WP to retrieve all categories in the query — that would be great. But, true, I would want to include only specific one(s), thereby excluding others.

    Guess I am accustomed to this feature in Drupal Views. Your WP plugin is a godsend, and my fave. So, thanks for taking it as far as you can, and continuing to expand it.

    Maybe there is a WP taxonomy plugin to isolate better — vocabulary and terms? I haven’t really explored that.

    Plugin Author Jonathan Daggerhart

    (@daggerhart)

    Hi tyme,

    My favorite way to use WP is like Drupal, so one of the first things I get is a Content Type creator plugin and a fields plugin.

    Using Advanced Custom Fields, you could create a taxonomy field on your posts that only allow for 1 term. Still in ACF, you can configure that field’s output. Then in Query Wrangler you can add that field to a query using the “Meta value” QW field type. With ACF installed, you’ll see an option to choose ACF as the display handler for that field, and this should give you the results you’re looking for. From there, all you have to do is Group by that field in the Row Style settings.

    Hope this helps,
    Jonathan

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Group by category?’ is closed to new replies.