Trouble building a custom WP_query

I’m trying to override the default query on my client’s single.php page and can’t seem to affect the query at all, despite seemingly doing it correctly (guess not!).

I simply want to eliminate one category of posts from the query. Its slug is “homepage-item” and its category is 10 (when I hover over its name in the Dashboard listing of categories, I see (in part): “…taxonomy=category&tag_ID=10…”

I’ve simply inserted this near the top of my single.php:

<?php
$customArgs = array(
‘category__not_in’ => ’10’
);
$custom_query = new WP_Query( $customArgs );
?>

…and I added my custom query’s variable name here:

<?php
if ( $custom_query->have_posts() ) { $count = 0;
while ( $custom_query->have_posts() ) { $custom_query->the_post(); $count++;
?>

But whatever I do, my query seems unaffected – the same content appears. I even tried changing $customArgs to remove virtually all content but see no change.

I’m sure I’m missing something obvious, but… what might it be?

Hope someone can help!
Adam

Read more here:: Trouble building a custom WP_query

Leave a Reply

Your email address will not be published. Required fields are marked *