Skip to content

Instantly share code, notes, and snippets.

@thefrosty
Last active December 10, 2015 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thefrosty/4459027 to your computer and use it in GitHub Desktop.
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?
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;
}
@thefrosty
Copy link
Author

Fixed it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment