Last active
December 10, 2015 16:08
-
-
Save thefrosty/4459027 to your computer and use it in GitHub Desktop.
The function works fine, but the $my_account and $my_account_pages are not merging. Getting an empty array in $my_account after merge. Not before though. Thoughts?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_extendd_my_account_pages() { | |
$all_wp_pages = wp_cache_get( 'extendd_my_account_pages' ); | |
if ( false === $all_wp_pages ) { | |
// Set up the objects needed | |
$the_query = new WP_Query(); | |
$all_wp_pages = $the_query->query( array( 'post_type' => 'page' ) ); | |
wp_cache_set( 'extendd_my_account_pages', $all_wp_pages ); | |
} | |
// Get the page as an Object | |
$my_account = get_page_by_title( 'My Account' ); | |
// Filter through all pages and find Portfolio's children | |
$my_account_pages = get_page_children( $my_account->ID, $all_wp_pages ); | |
$my_account_page_ids = $my_account->ID; | |
if ( is_array( $my_account_pages ) ) { | |
foreach ( $my_account_pages as $page ) { | |
$my_account_page_ids .= ',' . $page->ID; | |
} | |
} | |
$my_account_pages = get_pages( array( 'include' => $my_account_page_ids, 'child_of' => 1 ) ); | |
return $my_account_pages; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fixed it!