Some help with a code snippet?
-
I’m trying to concoct a code snippet that, when viewing a parent page or its children, will show only the children of said parent in the side bar.
I can use the child_of argument to refer to a specific parent:
<?php wp_list_pages('child_of=3&title_li=<h2>' . __('Pages') . '</h2>' ); ?>
But that won’t detect which parent (or subsequent children) are in view.
Someone on another post posted this bit of code:
<?php
if($wp_query->is_page && !is_home()) {
$lp_param = "";
$lp_param = "title_li=&depth=1&child_of=" .
$wp_query->get_queried_object_id();
wp_list_pages($lp_param);
}
?>But a) the li is gone, and b) the list of children disappears whenever you look at any page other than the parent.
I’m new to WP, and don’t know how to write this code myself. Can anyone help?
- The topic ‘Some help with a code snippet?’ is closed to new replies.