WordPress.org

Ready to get started?Download WordPress

Forums

How to get current custom taxonomy (6 posts)

  1. Justin Cline
    Member
    Posted 4 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
    Member
    Posted 4 years ago #

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

    http://greatdanemaniac.com/tutorials-2/

  3. Justin Cline
    Member
    Posted 4 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
    Member
    Posted 4 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
    Member
    Posted 3 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;

    //Frankie

  6. GabrielCol
    Member
    Posted 3 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