• I’m quite stumped. get_post_ancestors is supposed to accept an integer ID, but I get no ancestors unless I pass the page object itself:

    include '../wp-load.php';
    
    $pages =& get_pages();
    
    foreach ( $pages as $page ) {
    	var_dump( $page->ID // = string "integer"
    		, (bool) get_post( $page->ID ) // = bool true
    		, get_post_ancestors( $page->ID ) // = empty array
    		, get_post_ancestors( get_post( $page->ID ) ) // = empty array
    		, get_post_ancestors( $page ) ); // = array ancestors (success)
    }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get_post_ancestors( $page->ID ) is always empty’ is closed to new replies.