如果我使用此代码(代码不完整,这是问题部分),帖子会正确显示。注意“新的WP\\U查询(\'cat=2,3,5,6,7,8,9”);”:
$catslugs = array(\'academic\',/*\'adventure\',*/ \'arts\', \'religious\', \'special-interest\', \'special-needs\', \'sports\',\'teen\');//Must upate as new Main categories are added
$out = array();
foreach($catslugs as $slug) {
array_push($out, get_category_by_slug($slug)->term_id);
$CatIDs= implode(\',\', $out);
}
//featured category ID = 153
//academic category ID = 2
//adventure category ID = 4
//arts category ID = 3
//religious category ID = 5
//special-interest category ID = 6
//special-needs category ID = 7
//sports category ID = 8
//teen category ID = 9
$CatIDsCode="\'cat=".$CatIDs."\'";
$camp_posts_bynumber = new WP_Query(\'cat=2,3,5,6,7,8,9\');
if( $camp_posts_bynumber->have_posts() ):
如果我把它改成这个,它不会。相反,它会显示所有类别,包括“未分类”。我做错了什么?是不是写着“have\\u posts()”的东西
$catslugs = array(\'academic\',/*\'adventure\',*/ \'arts\', \'religious\', \'special-interest\', \'special-needs\', \'sports\',\'teen\');//Must upate as new Main categories are added
$out = array();
foreach($catslugs as $slug) {
array_push($out, get_category_by_slug($slug)->term_id);
$CatIDs= implode(\',\', $out);
}
//featured category ID = 153
//academic category ID = 2
//adventure category ID = 4
//arts category ID = 3
//religious category ID = 5
//special-interest category ID = 6
//special-needs category ID = 7
//sports category ID = 8
//teen category ID = 9
$CatIDsCode="\'cat=".$CatIDs."\'";
$camp_posts_bynumber = new WP_Query($CatIDsCode);
if( $camp_posts_bynumber->have_posts() ):
或
$catslugs = array(\'academic\',/*\'adventure\',*/ \'arts\', \'religious\', \'special-interest\', \'special-needs\', \'sports\',\'teen\');//Must upate as new Main categories are added
$out = array();
foreach($catslugs as $slug) {
array_push($out, get_category_by_slug($slug)->term_id);
$CatIDs= implode(\',\', $out);
}
//featured category ID = 153
//academic category ID = 2
//adventure category ID = 4
//arts category ID = 3
//religious category ID = 5
//special-interest category ID = 6
//special-needs category ID = 7
//sports category ID = 8
//teen category ID = 9
$CatIDsCode="\'cat=".$CatIDs."\'";
$camp_posts_bynumber = new WP_Query($CatIDs);
if( $camp_posts_bynumber->have_posts() ):