techblog.willshouse.com/2011/01/15/how-to-remove-the-container-with-the-wp_nav_menu-function
Preview meta tags from the techblog.willshouse.com website.
Linked Hostnames
3Thumbnail

Search Engine Appearance
How to Remove the <ul> container with the wp_nav_menu function - Tech Blog (wh)
Although WordPress has an option to remove the container from the wp_nav_menu function, that is generally for the ` ` and not the ` ` that wraps the ` ` items. So, while you can use the options to remove the ` `, the ` ` will stay. It might be good to use a filter method like add_filter( ‘wp_nav_menu’, ‘remove_ul’ ) to accomplish the filter I have below, but that the filter was not being applied at the time of writing, so I (used to) recommend changing the `echo` option to `false`, and returning the value of the `wp_nav_menu` function to a variable, and then running a regular expression on it to remove the encompassing ` ` and ` `. This code worked for me, running WordPress 3.0.4: $options = array( ‘echo’ => false ,’container’ => false ); $menu = wp_nav_menu($options); echo preg_replace( array( ‘#^ ]*>#’, ‘# $#’ ), ”, $menu ); ###Use Site Pages as a Default Fallback If you want it to use the site’s pages as a default (if no menu is specified and the function is called), you can add an additional function and change the options array as shown: function default_page_menu() { wp_list_pages(‘title_li=’); } $options = array( ‘echo’ => false ,’container’ => false ,’fallback_cb’=> ‘default_page_menu’ ); $menu = wp_nav_menu($options); echo preg_replace( array( ‘#^ ]*>#’, ‘# $#’ ), ”, $menu ); ###Update: A Better Way to Remove the ` ` element I think as of WordPress 3.1 they added a new parameter to make it … Continue reading →
Bing
How to Remove the <ul> container with the wp_nav_menu function - Tech Blog (wh)
Although WordPress has an option to remove the container from the wp_nav_menu function, that is generally for the ` ` and not the ` ` that wraps the ` ` items. So, while you can use the options to remove the ` `, the ` ` will stay. It might be good to use a filter method like add_filter( ‘wp_nav_menu’, ‘remove_ul’ ) to accomplish the filter I have below, but that the filter was not being applied at the time of writing, so I (used to) recommend changing the `echo` option to `false`, and returning the value of the `wp_nav_menu` function to a variable, and then running a regular expression on it to remove the encompassing ` ` and ` `. This code worked for me, running WordPress 3.0.4: $options = array( ‘echo’ => false ,’container’ => false ); $menu = wp_nav_menu($options); echo preg_replace( array( ‘#^ ]*>#’, ‘# $#’ ), ”, $menu ); ###Use Site Pages as a Default Fallback If you want it to use the site’s pages as a default (if no menu is specified and the function is called), you can add an additional function and change the options array as shown: function default_page_menu() { wp_list_pages(‘title_li=’); } $options = array( ‘echo’ => false ,’container’ => false ,’fallback_cb’=> ‘default_page_menu’ ); $menu = wp_nav_menu($options); echo preg_replace( array( ‘#^ ]*>#’, ‘# $#’ ), ”, $menu ); ###Update: A Better Way to Remove the ` ` element I think as of WordPress 3.1 they added a new parameter to make it … Continue reading →
DuckDuckGo
How to Remove the <ul> container with the wp_nav_menu function - Tech Blog (wh)
Although WordPress has an option to remove the container from the wp_nav_menu function, that is generally for the ` ` and not the ` ` that wraps the ` ` items. So, while you can use the options to remove the ` `, the ` ` will stay. It might be good to use a filter method like add_filter( ‘wp_nav_menu’, ‘remove_ul’ ) to accomplish the filter I have below, but that the filter was not being applied at the time of writing, so I (used to) recommend changing the `echo` option to `false`, and returning the value of the `wp_nav_menu` function to a variable, and then running a regular expression on it to remove the encompassing ` ` and ` `. This code worked for me, running WordPress 3.0.4: $options = array( ‘echo’ => false ,’container’ => false ); $menu = wp_nav_menu($options); echo preg_replace( array( ‘#^ ]*>#’, ‘# $#’ ), ”, $menu ); ###Use Site Pages as a Default Fallback If you want it to use the site’s pages as a default (if no menu is specified and the function is called), you can add an additional function and change the options array as shown: function default_page_menu() { wp_list_pages(‘title_li=’); } $options = array( ‘echo’ => false ,’container’ => false ,’fallback_cb’=> ‘default_page_menu’ ); $menu = wp_nav_menu($options); echo preg_replace( array( ‘#^ ]*>#’, ‘# $#’ ), ”, $menu ); ###Update: A Better Way to Remove the ` ` element I think as of WordPress 3.1 they added a new parameter to make it … Continue reading →
General Meta Tags
8- titleHow to Remove the <ul> container with the wp_nav_menu function - Tech Blog (wh)
- X-UA-CompatibleIE=edge,chrome=1
- charsetUTF-8
- viewportwidth=device-width, initial-scale=1.0
- robotsindex, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1
Open Graph Meta Tags
7og:locale
en_US- og:typearticle
- og:titleHow to Remove the <ul> container with the wp_nav_menu function - Tech Blog (wh)
- og:descriptionAlthough WordPress has an option to remove the container from the wp_nav_menu function, that is generally for the ` ` and not the ` ` that wraps the ` ` items. So, while you can use the options to remove the ` `, the ` ` will stay. It might be good to use a filter method like add_filter( ‘wp_nav_menu’, ‘remove_ul’ ) to accomplish the filter I have below, but that the filter was not being applied at the time of writing, so I (used to) recommend changing the `echo` option to `false`, and returning the value of the `wp_nav_menu` function to a variable, and then running a regular expression on it to remove the encompassing ` ` and ` `. This code worked for me, running WordPress 3.0.4: $options = array( ‘echo’ => false ,’container’ => false ); $menu = wp_nav_menu($options); echo preg_replace( array( ‘#^ ]*>#’, ‘# $#’ ), ”, $menu ); ###Use Site Pages as a Default Fallback If you want it to use the site’s pages as a default (if no menu is specified and the function is called), you can add an additional function and change the options array as shown: function default_page_menu() { wp_list_pages(‘title_li=’); } $options = array( ‘echo’ => false ,’container’ => false ,’fallback_cb’=> ‘default_page_menu’ ); $menu = wp_nav_menu($options); echo preg_replace( array( ‘#^ ]*>#’, ‘# $#’ ), ”, $menu ); ###Update: A Better Way to Remove the ` ` element I think as of WordPress 3.1 they added a new parameter to make it … Continue reading →
- og:urlhttps://techblog.willshouse.com/2011/01/15/how-to-remove-the-container-with-the-wp_nav_menu-function/
Twitter Meta Tags
4- twitter:label1Written by
- twitter:data1Will
- twitter:label2Est. reading time
- twitter:data22 minutes
Link Tags
5- canonicalhttps://techblog.willshouse.com/2011/01/15/how-to-remove-the-container-with-the-wp_nav_menu-function/
- shortcut iconhttps://techblog.willshouse.com/wp-content/themes/willshouse/img/favicon.ico
- stylesheethttps://techblog.willshouse.com/wp-includes/css/dist/block-library/style.min.css?ver=6.8.2
- stylesheethttps://techblog.willshouse.com/wp-content/plugins/wordpress-popular-posts/assets/css/wpp.css?ver=7.3.3
- stylesheethttps://techblog.willshouse.com/wp-content/themes/willshouse/css/main.css?ver=96249
Links
79- http://creativecommons.org/licenses/by-sa/2.5
- http://wikiduh.com/1541/custom-nav-menu-walker-function-to-add-classes
- https://techblog.willshouse.com
- https://techblog.willshouse.com/2011/01/14/applescript-to-unhide-restore-all-windows
- https://techblog.willshouse.com/2011/01/15/how-to-remove-the-container-with-the-wp_nav_menu-function