Deleted page still showing in menu
I created a menu using wp_list_pages to list all of the ancestors of the current page's parent—siblings, etc. Now my client has deleted a page, and deleted it from the trash, but it's still showing in the menu. No caching software is being used and I've flushed the permalinks multiple times. Any thoughts?
function my_page_tree_function() {
`$ID = get_the_ID();`
`$children = get_pages('child_of='.$ID);`
`$ancestors = get_post_ancestors($ID);`
`$ancestors = array_reverse($ancestors);`
`$ancestors[] = $ID;`
`global $post;`
`$subpages = wp_list_pages( array(`
`'echo' =>0,`
`'title_li' =>'',`
`'depth' =>2,`
`'child_of' => ( $post->post_parent == 0 ? $post->ID : $post->post_parent),`
`));`
`if(!$ID->post_parent):`
//echo '<h5><a href="' . get_permalink($ancestors[0]) . '">' . get_the_title($ancestors[0]) . '</a></h5>' . "\n";
$pages = get_pages('sort_column=menu_order');
foreach ($pages as $page){
if (!in_array($page->post_parent,$ancestors)){
$exclude.=','.$page->ID;
}
}
echo '<nav class="school-menu"><ul class="subnav caps none">' . "\n";
//echo $subpages;
wp_list_pages('title_li=&depth=2&child_of=' . $ancestors[0] . '&sort_column=menu_order');
echo '</ul></nav>' . "\n";
`endif;`
}
add_shortcode('my_page_tree', 'my_page_tree_function');
Posted Aug 7, 2025, 4:40 PM UTC