我已经在函数中创建了自定义帖子类型。php文件。
我在服务菜单部分创建了4个类别,aa、bb、cc和dd,我试图为特定类别获取最新的5篇帖子,但我可以将其存档。
这是我的查询帖子:
query_posts(array(\'showposts\' => 5, \'post_type\' => array(\'servicios\'), \'cat\' => 14));
14是类别aa的id。例如,我尝试了标记id、类别名称和术语,但没有成功。我的问题是什么?
更新时间:
以下是我现在的论点:
$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\'
);
这是我生成的wp\\U查询的sql查询:
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
如果我删除“AND mt24xi\\u posts.post\\u type IN(\'post\',\'page\')”查询工作正常