WordPress.org

Ready to get started?Download WordPress

Forums

WP_Query accessing parent (2 posts)

  1. romenov
    Member
    Posted 5 years ago #

    Hello,

    I have the following code:

    $insearchofaparent = new WP_Query();
    $insearchofaparent->query('page_id=' . $post->post_parent);
    while ($insearchofaparent->have_posts()) : $insearchofaparent->the_post();
    	$blah2 = printf(the_title());
    endwhile;

    I am trying to get the ID of the page PARENT in the variable $blah2,
    but $blah2 = $insearchofaparent->post_parent; does not seem to do the trick, but the_title() does work,
    any tips would be welcome!

    thanks

  2. MichaelH
    Member
    Posted 5 years ago #

    So you are looking for the grandparent of $post->post_parent, because isn't that what this is:
    $blah2 = $insearchofaparent->post_parent

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags