Skip to content

Instantly share code, notes, and snippets.

@Rupashdas
Created May 21, 2022 04:23
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 Rupashdas/ab8db92c86cf2f9fa9729fa720a5a52c to your computer and use it in GitHub Desktop.
Save Rupashdas/ab8db92c86cf2f9fa9729fa720a5a52c to your computer and use it in GitHub Desktop.
<?php
function get_menu_items_by_registered_slug($menu_slug) {
$menu_items = array();
if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_slug ] ) ) {
$menu = get_term( $locations[ $menu_slug ] );
$menu_items = wp_get_nav_menu_items($menu->term_id);
}
return $menu_items;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment