I add a custom post type with custom taxonomy and i wish to get all postings into this by a template, but the result is 0
$args=array(
'post_type' => 'contents',
'post_status' => 'publish',
'tax_query' => array(
'taxonomy' => 'content-category',
'field' => 'id',
'terms' => array(5,26,28)
),
'meta_key' => 'fs16'
);
$query = new WP_Query($args);
The SQL-Query is followed (don’t know why):
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) JOIN wp_icl_translations t ON wp_posts.ID = t.element_id AND t.element_type = 'post_contents' JOIN wp_icl_languages l ON t.language_code=l.code AND l.active=1 WHERE 1=1 AND 0 = 1 AND wp_posts.post_type = 'contents' AND (wp_posts.post_status = 'publish') AND (wp_postmeta.meta_key = 'fsk16' ) AND t.language_code='en' GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10
What’s going wrong here?
The
taxonomy
,field
andterms
intax_query
should be two array-level deep instead of one. Quoted from the WP_Query page:So, your arguments shoud be like:
You may omit
'post_status' => 'publish'
since it’s the default value used anyway.Are you sure you want to pass so many arguments?
The following should be sufficient to just display the posts of that category.
The above code is taken from the WP Codex.