The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

How to get current custom taxonomy (6 posts)

  1. Justin Cline
    Posted 6 years ago #

    Ok, I've searched high and low and I'm not finding this.

    I'm using custom posts and custom taxonomies to add a "portfolio" section with project 'types' (using types, the same way one would normally use categories.

    I was to display projects in the same category at the bottom of a single page. I have the display working when I manually add the project 'type' slug. I'm not finding a way to dynamically pull the current post's 'type' (there will be only one) and show relevant others. Any help would be awesome. I can't believe this is so hard.

  2. greatdanemaniac
    Posted 6 years ago #

    Maybe my tutorial on displaying CPT's and custom taxonomies could help you


  3. Justin Cline
    Posted 6 years ago #

    Hmmm, I need to go the other way though... not knowing the $taxonomy of the post, and pulling it from the custom taxonomy that was set.

    Like get_the_category() would do. Thanks though!

  4. Justin Cline
    Posted 6 years ago #

    I was able to figure it out with this post: http://wordpress.org/support/topic/295170?replies=24

    Love the WP community, thanks guys

  5. Frankie Jarrett
    Posted 5 years ago #

    I think this may also be an easy solution for what you're looking for...

    $current_tax = get_query_var('your_tax_slug');
    echo $current_tax;


  6. GabrielCol
    Posted 5 years ago #

    To display the name of the taxonomy, no matter what taxonomy is:

    $value    = get_query_var($wp_query->query_vars['taxonomy']);
    echo get_term_by('slug',$value,$wp_query->query_vars['taxonomy']);

    Happy wordpressing ;)

Topic Closed

This topic has been closed to new replies.

About this Topic