我的建议是将不同的参数传递给Wp\\u查询类。
使用“cat”属性,传递类别ID。
<?php
$custom_query = new WP_Query(
array(
\'cat\' => \'1,2,3,4\'
\'post_type\' => \'my_post_type\',
\'posts_per_page\' => -1,
\'orderby\' => \'title\',
\'order\' => \'ASC\'
)
);
?>
或使用“category\\u name”属性将类别slug作为字符串参数传递。
<?php
$custom_query = new WP_Query(
array(
\'category_name\' => \'category1+category2\'
\'post_type\' => \'my_post_type\',
\'posts_per_page\' => -1,
\'orderby\' => \'title\',
\'order\' => \'ASC\'
)
);
?>
有关Wp\\U查询参数的详细信息:
http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters希望有帮助。祝你好运收件人: