PhotoDune

Help me out, ol' reliable forum

2000 posts
  • United States
  • Bought between 50 and 99 items
  • Has been a member for 3-4 years
  • Exclusive Author
ThemeOcean says

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?

2507 posts Put a Donk On It
  • Exclusive Author
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Attended a Community Meetup
  • Referred between 100 and 199 users
  • Contributed a Tutorial to a Tuts+ Site
+5 more
ThemeProvince says

This will work:


query_posts("product_categories=$cat");

2000 posts
  • United States
  • Bought between 50 and 99 items
  • Has been a member for 3-4 years
  • Exclusive Author
ThemeOcean says

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.)

2507 posts Put a Donk On It
  • Exclusive Author
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Attended a Community Meetup
  • Referred between 100 and 199 users
  • Contributed a Tutorial to a Tuts+ Site
+5 more
ThemeProvince says

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.

2000 posts
  • United States
  • Bought between 50 and 99 items
  • Has been a member for 3-4 years
  • Exclusive Author
ThemeOcean says

Nothing comes between the loop when I add product_categories parameter. It’s really weird..

by
by
by
by
by