Depth parameter not working; like to display children and *not* grandchildren
-
I’m trying to display the children of a post and not the grandchildren of the post. I’ve been trying to set the depth parameter, but for the life of me, I can’t get it to work. What am I missing?
<? global $post; $ancestors = get_post_ancestors( $post->ID); $ancestor = $ancestors[0]; $children_args = array( "child_of" => $ancestor, 'sort_column' => 'menu_order', 'depth' => 1 ); $children = get_pages($children_args); ?> <ul class="ancestor_menu"> <?php foreach ( $children as $child ): global $wp_query; $postID = $wp_query->post->ID; if($postID === $child->ID) { $active = ' class="current-menu-item"'; }; ?> <li<?=$active?>><a href="<?php echo $child->guid; ?>"><?php echo $child->post_title; ?></a></li> <?php unset($active); endforeach; ?> </ul>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Depth parameter not working; like to display children and *not* grandchildren’ is closed to new replies.