当一个页面有孩子时,我想在列表中添加一个ul,我会对所有post\\u类型进行foreach,所以我不认为我可以使用wp_list_pages. 我一直在尝试解决这个问题,但刚刚以以下内容结束upp:
// Check for children
$children = array();
foreach ( $values as $post ) {
if( $post->post_parent ) {
$children[] = $post->ID;
}
}
foreach ( $values as $post ) {
setup_postdata( $post );
if( in_array( $post->ID, $children ) ) {
$output .= \'<ul>\';
$output .= \'<li data-id="\'. $post->ID .\'" data-area="\'. $area[\'area\'] .\'"><p>\'. get_the_title() .\'</p><span>\'. __(\'Child\', \'blocks\') .\'</span></li>\';
$output .= \'</ul>\';
} else {
$output .= \'<li data-id="\'. $post->ID .\'" data-area="\'. $area[\'area\'] .\'"><p>\'. get_the_title() .\'</p><span>\'. __(\'Parent\', \'blocks\') .\'</span></li>\';
}
wp_reset_postdata();
}