Forum Replies Created

Viewing 1 replies (of 1 total)
  • I am looking for reverse functionality.

    I have a page by name ‘Parent Page’ and there are 5 child pages say ‘Page A’,’Page B’,’Page C’,’Page D’,’Page E’ which is under ‘Parent Page’. I want to get the parent page name listes when I am within any child page. I tried many and finally decided to write a custom code in sidebar.php

    <?php
    $post_obj = $wp_query->get_queried_object();
    $post_ID = $post_obj->ID;
    $post_title = $post_obj->post_title;
    $post_name = $post_obj->post_name;
    $post_ParentPage = $post_obj->post_parent;

    ?>

    <?php

    $querystr = “SELECT post_parent from wp_posts where ID=”.$post_ID;
    $pageposts = $wpdb->get_results($querystr, OBJECT);
    echo ‘
    ##’.$post_parent.’##’;
    ?>

    The problem is that the $post_parent always displays null. Can someone help me on this?

Viewing 1 replies (of 1 total)