WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

on my "Work" template used for the custom post type with the same name, I have the following code showing a list of titles for every "work". What I want to do is to display just on that list the "Works" that have the same Custom taxonomy than the current one.

<?php $loop = new WP_Query( array( 'post_type' => 'work', 'posts_per_page' => 10, 'orderby' => asc ); while ( $loop->have_posts() ) : $loop->the_post(); ?>

  • Any idea?

    share|improve this question

    Assuming that you are on a taxonomy or term page then you can simply use:

    //get current term
    $term_slug = get_query_var( 'term' );
    //get current taxonomy
    $taxonomyName = get_query_var( 'taxonomy' );
    $loop = new WP_Query( array(
        'post_type' => 'work', 
        'posts_per_page' => 10, 
        'orderby' => 'ASC',
        $taxonomyName => $term_slug); 
    while ( $loop->have_posts() ) : $loop->the_post(); 
    share|improve this answer
    Thanks for your answer! But couldn't make it work, anyway I will show all projects, not just taxonomy related. Thanks! – user7375 Jul 27 '11 at 5:45

    Your Answer


    By posting your answer, you agree to the privacy policy and terms of service.

    Not the answer you're looking for? Browse other questions tagged or ask your own question.