Support » How-To and Troubleshooting » Get Taxonomy term using wp_query

Get Taxonomy term using wp_query

  • Hi,
    i have a custom post type called tours with taxonomy called tourtypes and few terms i.e casual, adventure. My theme also have the option to choose how many items to be displayed on a page.

    The following code to query on the post type and no of item to be displayed. What i couldnt figure out is how to display the specific term that user choose from the menu

    $paged = get_query_string_paged();
    $counter = 1;
    $terms = (get_query_var('terms')) ? get_query_var('terms') : 1;
    $posts_per_page = get_option('theme_show_tour_items');
        if($posts_per_page == "") {
           $posts_per_page = get_option('posts_per_page');
    $my_query = new WP_Query(array('post_type' => 'tours',  'tourtypes' => $terms, 'paged' => $paged, 'posts_per_page' => $posts_per_page));
    if ( $my_query->have_posts() ) : while ( $my_query->have_posts() ) : $my_query->the_post(); ?>

  • The topic ‘Get Taxonomy term using wp_query’ is closed to new replies.