I am having issues when it comes to displaying a post based off two taxonomy selections. As of right now I am able to display my post based of one tax selection which is speakeryear. The problem is when I want to add my second tax which is placement_category and narrow it down based on its slug selection I am still displaying all my tax based off speaker year.

 <?php $args = array('showposts'=>25,'post_type'=>'test', 'taxonomy' => 'placement_category','field' => 'slug', 'terms' => 'test1', 'speakeryear' =>$options[year] );$query = new WP_Query($args);while ( $query->have_posts() ) : $query->the_post(); ?>   
  <article class="card-half">
 <?php endwhile; ?>

Here I am calling the post based off its tax selection, which only displays speakeryear tax.

 'taxonomy' => 'placement_category','field' => 'slug', 'terms' => 'test1',

I added the above tax to the query in hopes to narrow down my post visibility, but had no luck.

This is what I am trying to achieve display all post from tax speakeryear then all the post that are displayed from speakeryear I want it be narrowed down to placement_category based on its slug selection.

I am displaying placement_category slugs test1 and test2 in two different locations on my website. All tax names and slugs are correct on my site. What am I doing wrong in narrowing down my post?


It is now working with the updated code

 <?php $args = array('showposts'=>25,'post_type'=>'liaisons', 'speakeryear' =>$options[year] );$query = new WP_Query($args);while ( $query->have_posts() ) : $query->the_post();
      if( has_term( 'test1', 'placementcategory' ) ) {
 <article class="card-half">
<?php } endwhile; ?>
  • figured it out I removed the taxonomy code within my query and added if( has_term( 'test', 'placementcategory' ) ) { – bigant841 Sep 18 '16 at 0:33
  • 1
    @DaveRomseyjust did it thank you. I just can't accept my answer until two days. – bigant841 Sep 18 '16 at 0:43

figured it out I removed the taxonomy code within my query and added

  <?php $args = array(
               'speakeryear' =>$options[year] 
  $query = new WP_Query($args);
    while ( $query->have_posts() ) : 
         if( has_term( 'test1', 'placementcategory' ) ) { ?> 
           <article class="card-half">Test</article>
   <?php }
    endwhile; ?>
| improve this answer | |
  • 2
    Glad you managed to work this out yourself +1 for that, but you might want to change the showposts to posts_per_page. Although showposts still functions with backward compatibility, the codex is showing showposts s depreciated and could come out anytime. thus breaking your code – Malisa Sep 18 '16 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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