WordPress.org

Ready to get started?Download WordPress

Forums

Query Multiple Taxonomies
[resolved] Adding Taxonomy Name in checkboxes-item.html (4 posts)

  1. schwarzgrau
    Member
    Posted 1 year ago #

    In checkboxes.html you can access the Name of the Taxonomy by using {{taxonomy}} but I need to access it in checkboxes-item.html to define a class like this
    <input type="checkbox" id="{{value}}" name="{{name}}" value="{{value}}" class="{{taxonomy}}" {{#is-selected}}checked="checked"{{/is-selected}} />

    I guess I have to change the data submitted to the Mustache-Template in walkers.php, but I don't know how.

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

  2. schwarzgrau
    Member
    Posted 1 year ago #

    Weird, I try to achieve something for hours and a few minutes after posting on the forum I find the solution.

    If someone else trying to do something similar, which propably never will happen:

    Replace this part (line 115) of walkers.php

    $data = array_merge( $data, array(
    			'term-name' => $term->name,
    			'is-selected' => in_array( $term->slug, $this->selected_terms ) ? array(true) : false,
    			'depth' => $depth,
    		) );

    with this

    $data = array_merge( $data, array(
    			'term-name' => $term->name,
    			'is-selected' => in_array( $term->slug, $this->selected_terms ) ? array(true) : false,
    			'depth' => $depth,
    			'tax-name' => $term->taxonomy
    		) );

    and use {{tax-name}} in the checkboxes-item.html

  3. groomedmonkey
    Member
    Posted 1 year ago #

    Hey thanks for posting that! It helped me work out how to add the term slug as a class so one can custom style each checkbox label individually:

    'term-slug' => $term->slug

    As above and use {{term-slug}} in template files.

  4. schwarzgrau
    Member
    Posted 1 year ago #

    glad to hear someone could use this stuff.
    By the way, I guess it's ok to change core files, since the plugin will never been updated.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic