{"flag":true,"single":true,"pageTitle":"Wordpress nav menu: wp_nav_menu()","post":{"id":229,"user_id":"1","slug":"wordpress-nav-menu-wp-nav-menu--pohp","title":"Wordpress nav menu: wp_nav_menu()","body":"<p>Syntax:<\/p>\r\n<pre class=\"language-php\"><code>wp_nav_menu( array $args = array() ): void|string|false<\/code><\/pre>\r\n<p>Simple function call will responce:<\/p>\r\n<pre class=\"language-php\"><code>&lt;?php wp_nav_menu(); ?&gt;<\/code><\/pre>\r\n<pre class=\"language-markup\"><code>&lt;div class=\"menu\"&gt;\r\n  &lt;ul&gt;\r\n    &lt;li class=\"page_item page-item-17\"&gt;&lt;a href=\"http:\/\/localhost\/wordpress\/homepage\/\"&gt;HomePage&lt;\/a&gt;&lt;\/li&gt;\r\n    &lt;li class=\"page_item page-item-2\"&gt;&lt;a href=\"http:\/\/localhost\/wordpress\/sample-page\/\"&gt;Sample Page&lt;\/a&gt;&lt;\/li&gt;\r\n  &lt;\/ul&gt;\r\n&lt;\/div&gt;\r\n<\/code><\/pre>\r\n<p><strong>Parameters:<\/strong><\/p>\r\n<p><strong>1. menu <\/strong>&gt;&gt;Desired menu.&nbsp; Accepts a menu ID, slug, name, or object.<\/p>\r\n<p><strong>2. menu_class &gt;&gt; <\/strong>CSS class to use for the <strong>ul element<\/strong> which forms the menu.&nbsp;Default 'menu'.<br><strong>3. menu_id&nbsp; &gt;&gt;<\/strong>The ID that is applied to the<strong> ul element<\/strong> which forms the menu.&nbsp;Default is the menu slug, incremented.<\/p>\r\n<pre class=\"language-php\"><code>wp_nav_menu(array(\r\n\t\"menu_class\" =&gt;\"wp_2020\",\r\n\t\"menu_id\" =&gt;\"wp_2020_id\"\r\n));<\/code><\/pre>\r\n<pre class=\"language-markup\"><code>&lt;div id=\"wp_2020_id\" class=\"wp_2020\"&gt;\r\n&lt;ul&gt;\/**\/&lt;\/ul&gt;\r\n&lt;\/div&gt;\r\n<\/code><\/pre>\r\n<p><strong>4. container &gt;&gt;<\/strong>Whether to wrap the ul, and what to wrap it with.&nbsp;<strong>Default <\/strong>'div'.<br><strong>5. container_class &gt;&gt;&nbsp; <\/strong>Class that is applied to the container.&nbsp;<strong>Default <\/strong>'menu-{menu slug}-container'.<br><strong>6. container_id <\/strong>The ID that is applied to the container.<br><strong>7. container_aria_label&nbsp; <\/strong>The aria-label attribute that is applied to the container when it's a nav element.<br><br><\/p>\r\n<pre class=\"language-php\"><code>wp_nav_menu(array(\r\n\t\"menu\"=&gt;\"menu-1\",\r\n\t\"container\" =&gt;\"nav\",\r\n\t\"container_class\"=&gt;\"nav_is l\",\r\n\t\"container_id\" =&gt; \"nav_2020\",\r\n\t\"container_aria_label\"=&gt;\"omg\"\r\n)); <\/code><\/pre>\r\n<pre class=\"language-markup\"><code>&lt;nav id=\"nav_2020\" class=\"nav_is l\" aria-label=\"omg\"&gt;\r\n  &lt;ul id=\"menu-menu-1\" class=\"menu\"&gt;\r\n    &lt;li id=\"menu-item-34\" class=\"menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-home menu-item-34\"&gt;\r\n      &lt;a href=\"http:\/\/localhost\/wordpress\/\" aria-current=\"page\"&gt;Home&lt;\/a&gt;\r\n    &lt;\/li&gt;\r\n  &lt;\/ul&gt;\r\n&lt;\/nav&gt;<\/code><\/pre>\r\n<p>https:\/\/developer.wordpress.org\/reference\/functions\/wp_nav_menu\/<\/p>","category_id":"29","is_private":"0","created_at":"2023-11-16T10:10:32.000000Z","updated_at":"2023-11-16T11:07:49.000000Z","category":{"id":29,"user_id":"1","name":"Wordpress","slug":"wordpress-uzoa","parent_id":"1","created_at":"2023-11-10T02:49:29.000000Z","updated_at":"2023-11-10T02:49:29.000000Z"},"user":{"id":1,"name":"R GONDAL","email":"rizikmw@gmail.com","email_verified_at":null,"two_factor_confirmed_at":null,"current_team_id":"1","profile_photo_path":null,"created_at":"2023-03-12T10:49:33.000000Z","updated_at":"2025-01-10T12:59:00.000000Z","profile_photo_url":"https:\/\/ui-avatars.com\/api\/?name=R+G&color=7F9CF5&background=EBF4FF"}},"pageDesc":"Syntax: wp_nav_menu( array $args = array() ): void|string|false Simple function call will responce: &lt;?php wp_nav_menu(); ?&gt; &lt;div cl - Wordpress nav menu: wp_nav_menu() (Updated: November 16, 2023) - Read more about Wordpress nav menu: wp_nav_menu() at my programming site [SITE]","categories":[]}