WordPress.org

Support

Support » Plugins and Hacks » Query Multiple Taxonomies » [Resolved] [Plugin: Query Multiple Taxonomies] Hierarchical Taxonomies and Categories

[Resolved] [Plugin: Query Multiple Taxonomies] Hierarchical Taxonomies and Categories

  • Hey scribu

    thanks for all the good work on this extremely useful plugin. I do have a question though.

    I have a custom hierarchical Make/Model taxonomy where the first level (parent) is a make (ie. Canon, HTC, etc…) and the second level (children) are the models the make has. This is tied into the categories which are the type of product (ie. Digital Cameras, Mobile Phones, etc…) and are also hierarchical.

    What I want is to be able to display the filtering widget with drop-downs populated in a tree-like hierarchical structure as opposed to the current one-level view. I know WordPress does this so I was wondering if there is a way to add this to the widget. I don’t mind coding it myself if you give me some pointers.

    I identified that the work is done in: qmt_get_terms() which either calls: QMT_Terms::get( $tax ) or get_terms( $tax ) but how to get the ‘nested’ terms from there?

    TIA, Robert

    http://wordpress.org/extend/plugins/query-multiple-taxonomies/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author scribu

    @scribu

    Well, you would need to use the Walker_CategoryDropdown class defined in wp-includes/classes.php.

    See query-multiple-taxonomies/widget.php

    Plugin Author scribu

    @scribu

    I landed this in the development version (1.3.1-alpha2).

    Thanks for addressing this so quickly. Shows up quite nicely however it uses IDs to pass to the query string instead of the category and taxonomy slugs so there are no results… is this due to the change you made?

    I Haven’t had a good look at the code yet…

    Plugin Author scribu

    @scribu

    Ah… forgot about that. I’ll take another look.

    Having had a look, you need to override Walker_CategoryDropdown and implement your own start_el() method since the original hard-codes using the term id.

    Then you can do:
    $walker = new QMT_Category_Walker();
    and pass your walker to the dropdown function:

    walk_category_dropdown_tree( $terms, 0, array(
        'selected' => qmt_get_query( $taxonomy ),
        'show_count' => true,
        'show_last_update' => false,
        'hierarchical' => true,
        'walker' => $walker,
    ) )

    Plugin Author scribu

    @scribu

    Yep, that’s just what I did. See the development version (1.3.1-alpha3).

    Maybe I should let you write the next version. 😛

    Hm, I will probably make some mods to the widget code to customize it to the needs of my current project.

    As it stands, there is a lot of ‘presentation’ stuff in the code so it’s not easy to customize it without touching the core plugin. Maybe you can look at providing some filter hooks for certain areas…

    If I end up with some mods that could be useful to others, I can pass the code onto you to include in your plugin if you want.

    Plugin Author scribu

    @scribu

    It already has several filters, but patches are always welcome.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Resolved] [Plugin: Query Multiple Taxonomies] Hierarchical Taxonomies and Categories’ is closed to new replies.
Skip to toolbar