So, I’m using these args for a query:
$args = array( 'tax_query' => array( 'taxonomy' => 'product_categories', 'field' => 'slug', 'terms' => array($cat) ) );
and it returns NO posts. I’ve ran over this several times and tried a different way, but I just can’t get it. $cat is exactly what it should be, the slug of the category (which has 22 products in it). Help please?
This will work:
Doesn’t work and neither does this:
$args = array( 'post_type' => 'products', 'product_categories' => $cat );
Mind you this is an external file, it isn’t being included in anything like header.php, it just has this for loading in WP:
<?php define('WP_USE_THEMES', false); require('/wp-load.php'); ?>
also, I get posts if I don’t enter any parameters, or if I just have the post_type parameter.
(I’m also 100% sure product_categories is the correct category taxonomy.)
That works on all my themes plus external clients’ themes.
Can you echo out anything in the loop?
You could try
global $post;in front of the loop if so.