Last active
May 4, 2018 19:30
-
-
Save anatol06/5e252c040b001adc2beb7c1c1065d8cc to your computer and use it in GitHub Desktop.
WP - Get Submenu Items
This file contains hidden or 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
// Get Top Parent Page (in functions.php) | |
function get_top_parent() { | |
global $post; | |
if($post->post_parent) { | |
$ancestors = array_reverse(get_post_ancestors($post->ID)); | |
return $ancestors[0]; | |
} | |
return $post->ID; | |
} | |
// Get submenu items (insert in page submenu) | |
$args = array( | |
'child_of' => get_top_parent(), | |
'title_li' => '' | |
); | |
wp_list_pages($args); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment