Support » Fixing WordPress » Filter out custom taxonomy term on home page loop

  • What I want to do is remove any post from my front page loop that has a certain term in my custom taxonomy. Here is the code that I am trying to get to work:

    <?php $taxargs = array('tax_query' => array(array('taxonomy' => 'Models','field' => 'slug','terms' => 'model-accessories','operator' => 'NOT IN',))); ?>
                 <?php $recent = new WP_Query($taxargs."&cat=".get_theme_mod('featured_top_left')."&showposts=".get_theme_mod('featured_top_left_num')); while($recent->have_posts()) : $recent->the_post();?>

    Thankfully there aren’t any Syntax errors anymore that cause my front page to show an error and not load, but it still isn’t working. Are all of my tax_query variables right? I tried taking out the ."&cat=".get_theme_mod('featured_top_left') to see if they were having issues with being together, but that didn’t affect it in any way. I am still seeing posts marked with the ‘Accessories’ term plus all other terms in under the ‘Models’ taxonomy. Can anyone help out?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter dallasmoore

    (@dallasmoore)

    Here is the link to the query_posts page that I am pulling my tax_query info from http://codex.wordpress.org/Template_Tags/query_posts

    Thread Starter dallasmoore

    (@dallasmoore)

    Okay, well I have went past the query post as a temporary fix and included an if statement inside the loop to check if a specific model is returned from strip_tags(get_the_term_list($post->ID, ‘Models’)). If so, I leave it blank, and then include the rest of the loop content after the <? else: ?>. The problem with this is, each of those posts are still included in the post counter, so my showposts=10 is reduced by however many posts it skipped. o.O Is there a workaround for this? Alternatively I am still open to fixing the original issue!

    Thanks.

    Edit: I tried adding my own counter in so that I could possibly go back and edit the query after the 10th post and add back the number of posts that were excluded, but by echoing the variable it only shows the original value before the loop started.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Filter out custom taxonomy term on home page loop’ is closed to new replies.