Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try getting the top ancestor id with <code>$topid = get_top_ancestor($postid);</code> then using the arguement <code>'child_of' =&gt; $topid</code> and be mindful of your <code>depth</code></p> <p>Full example:</p> <pre><code> &lt;?php $postid = get_the_ID(); $topid = get_top_ancestor($postid); $args = array( 'depth' =&gt; 2, 'show_date' =&gt; '', 'date_format' =&gt; get_option('date_format'), 'child_of' =&gt; $topid, 'exclude' =&gt; '', 'include' =&gt; '', 'echo' =&gt; 1, 'authors' =&gt; '', 'sort_order' =&gt; 'ASC', 'link_before' =&gt; '', 'link_after' =&gt; '', 'walker' =&gt; '', 'post_type' =&gt; 'page', 'post_status' =&gt; 'publish' ); ?&gt; &lt;ul&gt;&lt;?php wp_list_pages( $args ); ?&gt;&lt;/ul&gt; </code></pre> <p>Something for you to work on [Untested]:</p> <pre><code>function widget($args, $instance) { global $post; $postid = get_the_ID(); $topid = get_top_ancestor($postid); $args = array( 'depth' =&gt; 2, 'show_date' =&gt; '', 'date_format' =&gt; get_option('date_format'), 'child_of' =&gt; $topid, 'exclude' =&gt; '', 'include' =&gt; '', 'echo' =&gt; 1, 'authors' =&gt; '', 'sort_order' =&gt; 'ASC', 'link_before' =&gt; '', 'link_after' =&gt; '', 'walker' =&gt; '', 'post_type' =&gt; 'page', 'post_status' =&gt; 'publish' ); // if(empty($children) || is_page( array(17,125) ) ) return; // excludes contact us etc... // wp_reset_query(); $widget_title = $title; echo $before_widget; echo $before_title . $widget_title . $after_title; ?&gt; &lt;ul&gt; &lt;?php wp_list_pages( $args ); ?&gt; &lt;/ul&gt; &lt;?php echo $after_widget; wp_reset_postdata(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload