Support » Themes and Templates » 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:

    if($wp_query->is_page && !is_home()) {
    $lp_param = "";
    $lp_param = "title_li=&depth=1&child_of=" .

    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?

Viewing 6 replies - 1 through 6 (of 6 total)
  • please help!

    i really hate to bump, but i’m in a bad way on this.

    Really? No takers at all?

    i’m new to WP, so i won’t be much help to you but i feel bad for you. so i gave the code above a go.

    this piece of code appears to be hard-wiring to show the children of a particular page, and if you put it in the side-bar it will appear on all pages.
    <?php wp_list_pages(‘child_of=3&title_li=<h2>’ . __(‘Pages’) . ‘</h2>’ ); ?>

    this piece put out nothing for me at all, but i can see that it is checking if the current page is ‘home’.

    <?php if($wp_query->is_page && !is_home()) {
    $lp_param = “”;
    $lp_param = “title_li=&depth=1&child_of=” .

    so i did a search for keywords, child parent page and came up with these posts, which i will dig into now… i’ll get back to you if i can finger something out.

    in terms of getting feedback- i’ve noticed we might get better response by giving our posts keyworded titles like ‘Show only child pages’ or something like that. Since the forums only list *so very few* recent posts on the first page- only the last few hours show up. So you might get more response by people searching for same topic, and that’s where the title is important!


    I appreciate your desire to help; unfortunately, I read all of those posts before I posted this one.

    At one point, someone purported to have solved the problem, but never posted the solution.

    i think this is what you’re looking for.

    scroll down and read about the child_of parameter

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Some help with a code snippet?’ is closed to new replies.