Support » Plugins » WP_Query accessing parent

  • 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());

    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!


Viewing 1 replies (of 1 total)
  • So you are looking for the grandparent of $post->post_parent, because isn’t that what this is:
    $blah2 = $insearchofaparent->post_parent

Viewing 1 replies (of 1 total)
  • The topic ‘WP_Query accessing parent’ is closed to new replies.