This has been driving me nuts for hours. I've checked numerous pages on the web for an answer but I can't find one. I'm trying to get all of the posts from a custom post type, that are attached to an array of taxonomy ids. Here's the code
$args = array(
'post_type' => 'contractors',
'showposts' => -1,
'tax_query' => array(
array(
'taxonomy' => $taxonomy,
'terms' => $taxarray,
'field' => 'id'
)
)
);
$query = new WP_Query($args);
If you're wondering about the variables...
$taxonomy="service_type"; //and yes, this exists
$taxarray = array(24); //and yes, this id exists, and yes it has custom post types attached.
Basically, when I print_r($query), no posts are returned. Of course, I see all the other junk that spits out of it, but there's no posts. I'm pulling my hair out over this.
EDIT: I don't know if this is helpful, but a couple of things should be noted. I'm trying to do this inside a custom class->function, and I'm on the latest wordpress, and php 5+.
EDIT #2: New pastebin with fuller code: http://pastebin.com/px9N4LCV
FINAL EDIT: I figured out why it wasn't working. I was running the query too early, and Wordpress wasn't recognizing my taxonomy yet.