I have created a custom post types in function.php file.
I has created 4 categories on Service menu section, aa, bb, cc and dd, I try to get a latest 5 post for specific category but I can archive this.
this is my query post:
query_posts(array('showposts' => 5, 'post_type' => array('servicios'), 'cat' => 14));
14 is the id for category aa for example, I has tried Tag_ID, category_name and term instead cat and not work. What's wrong in my query?
UPDATE:
These are my argument right now:
$args = array(
'paged' => 1,
'posts_per_page' => '5',
'offset' => 0,
'post_status' => 'publish',
'ignore_sticky_posts' => 0,
'orderby' => 'date',
'order' => 'DESC',
'post_type' => array (
'servicios' => 'servicios',
),
'cat' => '15'
);
this is my generated sql query of wp_query:
SELECT SQL_CALC_FOUND_ROWS mt24xi_posts.ID FROM mt24xi_posts
INNER JOIN mt24xi_term_relationships ON (mt24xi_posts.ID = mt24xi_term_relationships.object_id) WHERE 1=1
AND ( mt24xi_term_relationships.term_taxonomy_id IN (12) )
AND mt24xi_posts.post_type IN ('post', 'page')
AND (mt24xi_posts.post_status = 'publish' OR mt24xi_posts.post_author = 1
AND mt24xi_posts.post_status = 'private')
GROUP BY mt24xi_posts.ID ORDER BY mt24xi_posts.post_date DESC LIMIT 0, 5
If I remove "AND mt24xi_posts.post_type IN ('post', 'page')" the query work fine