我试图查看带有一些描述的子页面名称列表来显示..我使用下面的代码
$my_wp_query = new WP_Query();
$all_wp_pages = $my_wp_query->query(array('post_type' => 'page'));
// Get the page as an Object
$portfolio = get_page_by_title('service');
// Filter through all pages and find Portfolio's children
$portfolio_children = get_page_children( $portfolio->ID, $all_wp_pages );
// echo what we get back from WP to the browser
echo "<pre>";print_r(
);
foreach($portfolio_children as $pagedet):
echo $pagedet['post_title'];
endforeach;
在使用 foreach 之前我正在获取数组
when i print $portfolio_children iam getting out put like this
Array
(
[0] => WP_Post Object
(
[ID] => 201
[post_title] => Website Hosting
)
[1]=> WP_Post Object
(
[ID] => 202
[post_title] => Website
)
在 foreach 之后,如果我打印 $pagedet 我得到
WP_Post Object
(
[ID] => 201
[post_title] => Website Hosting
)
我试图打电话给 $pagedet['post_title'] 但 id 没有显示任何东西......提前谢谢