1

What to do in situation when I don't have an ordinary if-while loop, how do I get permalink?

$page_children = get_page_children( 8, $all_wp_pages );

foreach( $page_children as $page ) :

    echo $page->post_title;
    the_permalink();

endforeach;

1 Answer 1

3

You should use get_permalink function and pass $page as an argument.

foreach( $page_children as $page ) :

  echo $page->post_title;
  get_permalink($page);

endforeach;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.