$post>ID displays wrong post ID

If i understand correctly you are trying to display a list of child pages of a page in a widget, if so then first check if you are on a page using the conditional tag is_page()
then you can use $wp_query->get_queried_object_id() like t31os has pointed out so your widget display function should look like this:

if (is_page()){
    Global $wp_query;
    $current_page_id = $wp_query->get_queried_object_id();
    $children = wp_list_pages('title_li=&child_of=".$current_page_id."&echo=0');
    echo $children;
}

So only if you are on a page this code will run

Leave a Comment