我已经解决了这个问题,只需要把if条件,这里是代码
$arr[0] = array(2=>2983);
$arr[1] = array(2=>2981);
$arr[2] = array('A'=>20);
$arr[3] = array('A'=>25);
print "<pre>";
print_r($arr);
$newArry = array();
foreach ($arr as $a) {
foreach ($a as $key => $value) {
if (array_key_exists($key, $newArry)) {
//$newArry[$key] = array($value);
array_push($newArry[$key], $value);
} else {
$newArry[$key] = array($value);
}
echo "<br/> Key ".$key ." => Value ".$value;
//print_r($b);
}
}
print_r($newArry);
您可以使用WP_Query,因为页面只是一种帖子类型。
$args = array(
'post_type' => 'page',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC',
);
$query = new WP_Query( $args );
$pages = $query->posts;