Title: wordpress ancestors
Last modified: August 20, 2016

---

# wordpress ancestors

 *  [obgaoml](https://wordpress.org/support/users/obgaoml/)
 * (@obgaoml)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/wordpress-ancestors/)
 * I’d like to get page list from the bottom level to the 2nd level, NO TOP LEVEL.
 * `echo $ancestors = wp_list_pages("title_li=&child_of=".$ancestors."&echo=0&depth
   =3");`
 * am close to the result, but my output from last level to TOP level. how can minus
   one level to the 2nd ?
 * Thanks

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Rocco Tripaldi](https://wordpress.org/support/users/roccotripaldi/)
 * (@roccotripaldi)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/wordpress-ancestors/#post-3598111)
 * You could first get an array of post_ids for the top-level pages like so:
 *     ```
       $exclusion_args = array(
       	'post_type' => 'page',
       	'post_parent' => 0,  // only exclude top level
       	'fields'=>'ids', // only need the ids
       );
   
       $exclusion_query = new WP_Query($exclusion_args);
       $exclusion_ids = $exclusion_query->posts;
       $exclusion_ids_string = implode(',',$exclusion_ids);
       ```
   
 * And then you could pass the exclusion ids like so
    `wp_list_pages("title_li=&
   child_of=".$ancestors."&echo=0&depth=3&exclude=".$exclusion_ids_string);`
 * Hope it helps.
 *  Thread Starter [obgaoml](https://wordpress.org/support/users/obgaoml/)
 * (@obgaoml)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/wordpress-ancestors/#post-3598148)
 * [@roccotripaldi](https://wordpress.org/support/users/roccotripaldi/) thanks a
   lot. that works
    However, when I change to another page, it doesn’t show relative
   page’s child pages

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘wordpress ancestors’ is closed to new replies.

## Tags

 * [ancestors](https://wordpress.org/support/topic-tag/ancestors/)
 * [wp_list_pages](https://wordpress.org/support/topic-tag/wp_list_pages/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [obgaoml](https://wordpress.org/support/users/obgaoml/)
 * Last activity: [13 years, 1 month ago](https://wordpress.org/support/topic/wordpress-ancestors/#post-3598148)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
