WordPress.org

Ready to get started?Download WordPress

Forums

_page_level_out? (1 post)

  1. syrupcore
    Member
    Posted 9 years ago #

    I'm still struggling with displaying the siblings of a given page in the sidebar. I was looking at the "_page_level_out" function, wondering if that's my key to utopia? I cant find anything about it in the codex and very little here on the baord.

    I have some code I've found through searching that is displaying the child pages, if there are child pages. Can some one see how I might modify this to display the "child pages of the parent page, _IF_ this page has a parent"

    here's my code thus far:
    <?php
    $current_page = $post->ID;
    $parent = 1;

    while($parent) {
    $page_query = $wpdb->get_row("SELECT post_name, post_parent FROM $wpdb->posts WHERE ID = '$current_page'");
    $parent = $current_page = $page_query->post_parent;
    if(!$parent)
    $parent_name = $page_query->post_name;
    }
    ?>

    <?php global $id; // the page id

    $kids = get_pages("child_of=$id");
    if (count($kids) > 0) {wp_list_pages('child_of=' . $id . '&title_li=&sort_column=menu_order');}
    elseif (count($kids) == 0) {wp_list_pages('child_of=' . $parent_name . '&title_li=&sort_column=menu_order');}

    ?>

    I've been hacking away but nothing seems to work. please help.

    Thanks,
    Will

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags