Skip to content

Instantly share code, notes, and snippets.

@shaddam
Created September 18, 2019 08:56
Show Gist options
  • Select an option

  • Save shaddam/3a4e27bc088ed4d035cd0c0b3fb324de to your computer and use it in GitHub Desktop.

Select an option

Save shaddam/3a4e27bc088ed4d035cd0c0b3fb324de to your computer and use it in GitHub Desktop.
add nav menu list in elementor widget
this code for function file
// select nav menu list
function select_nav_menu(){
$menus = wp_get_nav_menus();
$menulists = [];
foreach( $menus as $menu ){
$menulists[ $menu->slug ] = $menu->name;
}
return $menulists;
}
// paste code where you want to show menu
$args = array(
'menu' => $select_menu,
'menu_id' => 'menu-'. $id
);
wp_nav_menu( $args );
// elementor control
$this->add_control(
'select_menu',
[
'label' => __( 'Select Menu', 'brenda' ),
'type' => Controls_Manager::SELECT2,
'options' => select_nav_menu(),
]
);
// bottom of the elementor settings display
$select_menu = $settings['select_menu'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment