当然这是可能的。看看吧docs for wp_list_pages
所以像这样的事情可以做到:
<?php
global $post; // assuming there is global $post already set in your context
wp_list_pages( array(
\'exclude\' => $post->ID, // exclude current post
\'parent\' => $post->post_parent // get only children of parent of current post
) );
?>
如果您想使用一些自定义HTML,那么下面的内容应该会有所帮助:
<?php
global $post; // assuming there is global $post already set in your context
if ( $post->post_parent ) : // if it\'s a child
$siblings = new WP_Query( array(
\'post_type\' => \'page\',
\'post_parent\' => $post->post_parent,
\'post__not_in\' => array( $post->ID )
) );
if ( $siblings->have_posts() ) :
?>
<ul>
<?php while ( $siblings->have_posts() ) : $siblings->the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; wp_reset_postdata(); ?>
</ul>
<?php
endif;
endif;
?>