Note that there are some explanatory texts on larger screens.

plurals
  1. POfunction not returning value in "functions.php"
    text
    copied!<p>I have created a function within my themes <code>functions.php</code> file in order to persist a list of child pages from the level of a parent page while navigating deeper within the hierarchy.<br> My issue is that when I call the function within the <code>page.php</code> theme file I dont get anything back.</p> <p><strong>functions.php:</strong></p> <pre><code>function get_top_parent_children($the_id,$start = 0,$walk = null){ $current_post = get_post($the_id); $walk[] = $current_post; if($current_post-&gt;post_parent){ get_top_parent_children($current_post-&gt;post_parent,$start,$walk); } else { $output = array_reverse($walk); return get_children($output[$start]-&gt;ID); } } </code></pre> <p><strong>page.php:</strong></p> <pre><code>&lt;?php get_header(); ?&gt; &lt;div id="primary" class="clearfix"&gt; &lt;div id="content"&gt; &lt;?php the_post(); ?&gt; &lt;?php $children = get_top_parent_children($id,1); ?&gt; &lt;?php if ( $children ) { ?&gt; &lt;section id="post-topic"&gt; &lt;h2&gt;&lt;?php the_title() ?&gt; Topics&lt;/h2&gt; &lt;ul class="clearfix"&gt; &lt;?php foreach( $children as $child){ ?&gt; &lt;li&gt; &lt;a href="&lt;?php echo get_permalink($child-&gt;ID) ?&gt;"&gt; &lt;?php echo child-&gt;post_title ?&gt; &lt;/a&gt; &lt;/li&gt; &lt;?php }; ?&gt; &lt;/ul&gt; &lt;/section&gt; &lt;?php }; ?&gt; &lt;?php get_template_part( 'content', 'page' ); ?&gt; &lt;/div&gt; &lt;aside&gt; &lt;?php dynamic_sidebar('Page Sidebar'); ?&gt; &lt;/aside&gt; &lt;/div&gt; &lt;?php get_footer(); ?&gt; </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