So I've created a custom taxonomy type with a plugin (CMS Press) and now I'm trying to get all of the posts with the taxonomy terms in that taxonomy.
My get_posts looks like this:
$args = Array(
'numberposts' => 5,
'offset' => 0,
'post_status' => 'publish',
'content-type' => 'my-term'
);
get_posts($args);
I've also tried:
$args = Array(
'numberposts' => 5,
'offset' => 0,
'post_status' => 'publish',
'tax_query' => Array( Array (
'taxonomy' => 'content-type'
'field' => 'slug'
'terms' => 'my-term'
));
get_posts($args);
This works fine when I'm not using a custom taxonomy. if I change my request to:
$args = Array(
'numberposts' => 5,
'offset' => 0,
'post_status' => 'publish',
'tax_query' => Array( Array (
'taxonomy' => 'post_tags'
'field' => 'slug'
'terms' => 'some-tag'
));
get_posts($args);
it works.
I was wondering if there's something I'm leaving out that's preventing custom taxonomies from being queried. Any help would be appreciated.
$args = array( 'numberposts' = -1, 'post_status' = 'publish' );
etc. In case that helps. You can fill an array$arg['numberposts'] = -1
but again that's different to what you show. See php.net for more.get_posts
(plural) andget_post
is just a typo, alsopost_tags
(the built in taxonomy is singular,post_tag
). for the purpose of debugging I suggest usingWP_Query
rather thanget_posts
, then you can var_dump the query object to see the actual query being generated and sent to the database.