Forums

[resolved] Custom Taxonomies and current taxonomy term ID (5 posts)

  1. srhnbr
    Member
    Posted 2 years ago #

    I hope someone may be able to help me here.

    I have followed the excellent tutorial series here:
    http://justintadlock.com/archives/2009/05/06/custom-taxonomies-in-wordpress-28
    and here:
    http://justintadlock.com/archives/2009/06/04/using-custom-taxonomies-to-create-a-movie-database

    I find myself needing to retrieve the current custom taxonomy term ID similar how it is done here for tags:
    http://wordpress.org/support/topic/305892?replies=4

    what I'm using for tags is this inside the tag.php

    $term_id 			= get_query_var('tag_id');
    $taxonomy 			= 'post_tag';
    $args 				='include=' . $term_id;
    $terms 				= get_terms( $taxonomy, $args );

    Now I need to do the same for my custom taxonomy but I can't seem to nail it. What I don't understand is the tag_id in get_query_var('tag_id') is coming from where? Where can I find a list of the variable keys the get_query_var() function can take?

  2. srhnbr
    Member
    Posted 2 years ago #

    Never mind I got it!

  3. Mark / t31os
    Moderator
    Posted 2 years ago #

    This might may regarding the query_vars so you can see what's there..

    <pre><?php print_r($wp_query->query_vars); ?></pre>

    Also you may wish to consider posting your solution for other users.

  4. srhnbr
    Member
    Posted 2 years ago #

    @t31os_ that's right that's what I ended up doing then I found out that all I had to do was the following:

    $term_id 			= get_query_var('term_id');

    It was right there in front of me all the time!

  5. srhnbr
    Member
    Posted 2 years ago #

    forgot to mention that the above was used in the taxonomy.php

Topic Closed

This topic has been closed to new replies.

About this Topic