将get_pages()
为你工作?http://codex.wordpress.org/Function_Reference/get_pages
如果我正确理解了你的问题,你会想要这样的东西:
$children_of_page = get_pages(array(
\'child_of\' => $post->ID,
\'parent\' => $post->ID //defining both parent and child forces the list to only include direct children.
));
$children_of_first_child = get_pages(array(
\'child_of\' => $children_of_page[0][ID],
\'parent\' => $children_of_page[0][ID]
));
如果要直接输出列表,可以使用
wp_list_pages()
,
http://codex.wordpress.org/Template_Tags/wp_list_pages, 类似于:
wp_list_pages(array( //Get first level children of current page and output as list
\'child_of\' => $post->ID,
\'depth\' => 1,
\'title_li\' => \'\'
));
$children = get_pages(array(
\'child_of\' => $post->ID,
\'parent\' => $post->ID
));
wp_list_pages(array( //output the children of the first child
\'child_of\' => $children[0][ID],
\'depth\' => 1,
\'title_li\' => \'\'
));
根据需要打乱论据,以得到你想要的东西。