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?
- Exclusive Author
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Sold between 250 000 and 1 000 000 dollars
- Author was Featured
- Item was Featured
- Attended a Community Meetup
- Referred between 100 and 199 users
- Contributed a Tutorial to a Tuts+ Site
This will work:
query_posts("product_categories=$cat");
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.)
- Exclusive Author
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Sold between 250 000 and 1 000 000 dollars
- Author was Featured
- Item was Featured
- Attended a Community Meetup
- Referred between 100 and 199 users
- Contributed a Tutorial to a Tuts+ Site
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.
Nothing comes between the loop when I add product_categories parameter. It’s really weird..
