WordPress.org

Ready to get started?Download WordPress

Forums

Query Multiple Taxonomies
[resolved] [Plugin: Taxonomy Drill-Down] How to display tag's name of the 2nd taxonomy requested in url ? (6 posts)

  1. bouddhalight
    Member
    Posted 3 years ago #

    Hi,

    I have a custom post type with many many taxonomies. This is why I use this plugin.

    Here is my problem, For example :
    http://www.mywebsite.com/?taxonomyA=term1&taxonomyB=term2

    I would like to display (in my header.php template) the tag's name of only taxonomyB is it requested in url.

    I tried to use the following lines of code but it doesn't work :

    if (is_multitax( array('taxonomyB') )) {
    $taxonomyB_term = get_term_by( 'slug', get_query_var('term'), get_query_var('taxonomyB') );
    echo $term->name;
    }

    If anyone knows... ? :/

    Thanks!
    Bouddhalight

  2. bouddhalight
    Member
    Posted 3 years ago #

    Ok, I got it.

    if (is_multitax( array('taxonomyB') )) {
    foreach (qmt_get_query() as $tax => slug) {
      $tag = get_term_by( 'slug', $slug, $tax );
      if ( $tag->taxonomy == "taxonomyB") {
        echo $tag->name;
      }
    }

    [Please post code snippets between backticks or use the code button.]

    the foreach missed. ^^

  3. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    Glad to see you've managed on your own. :)

    Note that that if (is_multitax( array('taxonomyB') )) { check will not work for this url:

    ?taxonomyA=term&taxonomyB=another-term

    You can just remove the if check and it should work as expected.

  4. bouddhalight
    Member
    Posted 3 years ago #

    Thanks Scribu :)

    I have another question:
    I have to implement a menu "cities". The user can choose a city (or not) wich is a term of "city" taxonomy.
    So the url could be like that :
    http://www.website.com/city/city-term

    How can i set up your plugin to consider the city term ? :)

  5. bouddhalight
    Member
    Posted 3 years ago #

    Scribu ? please... :D

  6. bouddhalight
    Member
    Posted 3 years ago #

    I create new topic for the last question.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic