admin管理员组文章数量:1419666
Got this bit of code which runs which gets the Page ID and displays all the children under it. Which is good.
Part two of this is getting it to pull in the child of children items.
So currently looks like this
Main Menu Item
Child Item
Child Item
Child Item
But I need it to look like this
Main Menu Item
Child Item
Child Item
Child Item
Child Item
This is the code I am using
<?php
$args = array(
'post_type' => 'page',
'posts_per_page' => -1,
'post_parent' => 92,
);
$parent = new WP_Query( $args );
if ( $parent->have_posts() ) : ?>
<?php while ( $parent->have_posts() ) : $parent->the_post(); ?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
<?php endif; wp_reset_postdata(); ?>
Got this bit of code which runs which gets the Page ID and displays all the children under it. Which is good.
Part two of this is getting it to pull in the child of children items.
So currently looks like this
Main Menu Item
Child Item
Child Item
Child Item
But I need it to look like this
Main Menu Item
Child Item
Child Item
Child Item
Child Item
This is the code I am using
<?php
$args = array(
'post_type' => 'page',
'posts_per_page' => -1,
'post_parent' => 92,
);
$parent = new WP_Query( $args );
if ( $parent->have_posts() ) : ?>
<?php while ( $parent->have_posts() ) : $parent->the_post(); ?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
<?php endif; wp_reset_postdata(); ?>
Share
Improve this question
asked Jul 17, 2019 at 14:23
JamesJames
34 bronze badges
1 Answer
Reset to default 0You can do what you need to with the wp_list_pages()
function:
<?php
wp_list_pages(
[
'child_of' => 92,
'title_li' => false,
'sort_column' => 'menu_order',
]
);
?>
本文标签: phpGet Child of Child Pages in custom Menu
版权声明:本文标题:php - Get Child of Child Pages in custom Menu 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745315580a2653138.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论