How can I retrieve a list of a Wordpress page's sibling pages?

后端 未结 4 1888
忘了有多久
忘了有多久 2021-02-19 04:08

I am trying to create a list of sibling pages (not posts) in WordPress to populate a page\'s sidebar. The code I\'ve written successfully returns a page\'s parent\'s title.

4条回答
  •  青春惊慌失措
    2021-02-19 04:53

    wp_list_pages(array(
        'child_of' => $post->post_parent,
        'exclude' => $post->ID,
        'depth' => 1
    ));
    

    The correct answer, as both other answers don't exclusively display the siblings.

提交回复
热议问题