Questions tagged [menus]

Navigation Menu is a theme feature introduced with Version 3.0. WordPress includes an easy to use mechanism for introducing customised navigation menus into a theme. In order to incorporate menu support into your theme, you need to add a few code segments to your theme files.

798 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6
votes
1answer
890 views

Add data-icon input to Wordpress custom menu links

I need to add a data-icon="" input to my Wordpress Custom Menu input box thing. This is so I can use an icon font and type the code in for a specific icon and in the CSS use pseudo elements to match ...
5
votes
2answers
11k views

Add custom page link with anchor

In my admin section I would like to add in Appearance > Menus > some custom pages to add to my menu. I have two different menu one for the home page and one for the others pages. In my home page menu ...
5
votes
1answer
516 views

Link to Author archive from Navigation Menus in dashboard?

I'd like to display a grid of authors on my site showing the name of the author and their avatar. The tricky part is, I'd like to be able to control this from the Menus page in the dashboard so I have ...
4
votes
1answer
738 views

Custom Nav Walker menu - Display category count

I have a custom walker menu.( See the code below) I would like to have my nav menu like this: Where 495 is the total of the records containing childrens. Where 42 Number of published articles. Can ...
4
votes
1answer
2k views

Registering menu with 'Automatically add new top-level pages to this menu' selected

Is it possible to register a menu inside of a theme functions file and have 'Automatically add new top-level pages to this menu' pre-selected? I can't find any info about this in the ...
3
votes
1answer
176 views

Add Menu items description via Custom Walker for wp_nav_menu()?

Here is a solution I've found, and it works to append a description after the link. My question is: Is it also possible to append a description before the link? function add_description_to_menu($...
3
votes
1answer
241 views

Generate a tabbed submenu — from taxonomy term or submenu item — with sample content

I'm looking to generate a tabbed submenu from taxonomy term or submenu item and include sample content (three items per term/submenuu item). The styling I can do, the problem is the html generation. ...
3
votes
0answers
899 views

Create Custom Post Type Archive Page with Sub Categories Navigation Sidebar

I have 8 custom post types (which are actually for 8 different blogs and used as "blog landing pages"). Each custom post type is also a Blog Category and each has several sub categories to it. For ...
3
votes
0answers
1k views

How to add ID and class in nav menu walker?

I would like to set up a custom walker that produces the following output: <div id="navbarHolder"> <div id="navbar"> <ul> <li><a id="nav_about" ...
3
votes
1answer
749 views

Wrap description and sub menu in a wrapper

I am trying to add a wrapper to description and sub-menu in wordpress using walker class, Description will only be shown for the first menu so the structure will look like this EDIT I have been ...
3
votes
0answers
894 views

wp_nav_menu custom walker - child items

I have written a custom walker to integrate a jQuery drop-down nav script into my WordPress template. I need to add .dropdown-link to each of my parent menu items and .dropdown-wrapper to the ...
2
votes
0answers
25 views

Use walker for specific menu, or avoid use of walker

I'm trying to solve a particular problem and having trouble figuring out which way is best. So, I have a menu (generated through WP's menu creator) and would like to pull the featured image of each ...
2
votes
1answer
2k views

How do I give class to the dropdown sub-menu in the wp_nav_menu?

This is my html code <div class="section__main-nav" id="section__main-nav-id"> <div class="container"> <nav class="navbar navbar-toggleable-md navbar-light"&...
2
votes
0answers
88 views

Building custom API and using wp_get_nav_menu_items to get menu items. Only works when logged in, returns nothing when I'm not

Working on a custom api for a site I'm building and I found a weird issue with wp_get_nav_menu_items. Essentially - wp_get_nav_menu_items only works and returns items when I'm logged in. If I'm not ...
2
votes
0answers
87 views

Custom Category/Subcategory structure

I am building a site with several sections, and one of them is a special page to navigate through categories in a hierarchical style (you can navigate into categories/subcategories and see their ...
2
votes
0answers
238 views

wp_get_nav_menu_items return results are insane

I was hoping to create a plugin that adds a new post to a Menu on the second sub-items. However I can't ever seems to get the orders correctly it some times work and sometimes doesn't. Last thing I've ...
2
votes
0answers
537 views

Update Nav Menu Items Programmatically

I know this may sound stupid, but I created a code which (in theory) should add a few submenus to my primary menu. However I don't seem to be able to display this new menu because I don't know when I ...
2
votes
1answer
362 views

Replacing the NavWalker dropdown element

I'm creating a website for my school with Material Design for Bootstrap and the NavWalker is giving me some issues, I want to change the element of dropdown i.e. from ul to div. I've tried to edit the ...
2
votes
0answers
15 views

Change where navigation bar links?

I have a client with a WordPress blog who wants to have her website run two separate websites in the same WordPress installation by duplicating pages and changing the place that the navigation bar ...
2
votes
0answers
174 views

Programmatically create menu with custom link

I am creating pages and assign them to a menu with custom link. Pages are properly created and menu is properly created, too. However, custom links are not given to the menu items. What I want is to ...
2
votes
3answers
36 views

Remove Page Name From Wordpress Menu

I have a Wordpress menu that are both being used as a normal menu with page name that links to the page. I want to echo the same registered menu, but without the page name. To be clear, I still want ...
2
votes
0answers
104 views

Wordpress menu that shows all posts in a certain category like w3schools

I am working on creating a widget menu(kind of a sidebar like w3schools) that is supposed to show all posts that are listed in a particular category. And update automatically from particular category(...
2
votes
1answer
564 views

HTML in Menu Items disappear on save

I've created a menu that, instead of plain text, needs to have icons. Unfortunately the "CSS Classes" option provided by WP adds the class to the li rather than the a so the icon won't be clickable if ...
2
votes
1answer
413 views

How to display dynamic content in start_lvl function

I am creating a custom nav walker but having trouble outputting parent menu item title in start_lvl function. I want to output it right after the <div class="dropdown"> in the following ...
2
votes
1answer
1k views

Add div to specific sub-menu

I researched in google, yandex but had no success. With this code I can set a div to sub-menu but this code add to all sub-menus, I just need to add div to specific sub-menu. class Megratron_div ...
2
votes
2answers
911 views

How to add a parameter to <a> links in the nav menu?

I have to add itemprop="url" to the links of the links in the navbar of this site. In the settings I found the function wp_nav_menu(). Even after reading the WP codex, I am not able to make the ...
2
votes
0answers
707 views

Custom Loop through category menu to include sub categories

In my custom wordpress theme I currently have the below loop to the main categories <?php $menu = wp_get_nav_menu_object('navigation'); $items = wp_get_nav_menu_items($menu->term_id); foreach($...
2
votes
1answer
535 views

Automatically Add New Tags to Sub-menu

Been searching for any related plugins or info. about this case but didn't find anything relevant or working. I need every new tag that is added to a post automatically appear in a menu as a sub-menu ...
2
votes
1answer
1k views

List children of second level sub page

Top Level Page - Second Level Page --- Child Page --- Child Page --- Child Page The goal here is to list all children of second level, I have that done from the codex. However, when I click ...
2
votes
1answer
473 views

Set Item Order with wp_nav_menu_{$menu->slug}_items

I have some code that adds a menu item to a menu using wp_nav_menu_{$menu->slug}_items. It's pretty easy to add a menu item as the first or last item of the menu, but I was wondering if there's ...
2
votes
1answer
103 views

selected menu item

The template I'm working on for a client has the following pages: Home : a custom static page that displays the content of a certain WP page, and the latest sticky posts. This is the front-page.php ...
2
votes
1answer
302 views

How to move parent li to end of child ul

I'm working on translating a site from HTML/CSS to Wordpress, and I've come across an issue. In the spirit of keeping the site fully customizable from the dashboard, I've been using Wordpress' default ...
2
votes
1answer
647 views

How do I approach removing menu items on the fly based on settings in my plugin?

I've started writing a plugin that allows the administrator to select specific pages and set them to be visible only to logged-in users; the plugin optionally applies the restriction to all child ...
1
vote
2answers
16 views

Trouble creating conditional PHP for nav menu items with children for custom Walker

I'm trying to create a nav menu with a clickable dropdown function but minimize scripting at the same time, so I found out a way to achieve this with an invisible input box and CSS. My only problem is ...
1
vote
0answers
32 views

Automatically list top level menu item child pages

I am building a website that has a lot of pages. The client is not a big fan of the Wordpress menu builder works (in appearance -> menus), and we have come to the conclusion that the best way for the ...
1
vote
1answer
41 views

Is this best practice for Dynamically adding items to WordPress menus?

Is there an easier way too add this functionality to the menus page, instead of using the following code? Another words a different filter/hook/action that will make it, so I don't have to write ...
1
vote
0answers
154 views

Custom Walker_Nav_Menu issue with variables on PHP 7.3

I've made this custom walker that extends Walker_Nav_Menu for "mega menu" implementation. It works perfectly fine from PHP 5.4 to PHP 7.2, however it it has problems on PHP 7.3. The idea is to compare ...
1
vote
0answers
8 views

Add media library items to Menus using the Customizer (via Media Manager not URL)

You can add links to files in the media library URL via the Custom Links panel of the Customizer but for clients this requires multiple steps including cutting and pasting a URL from the media library ...
1
vote
1answer
361 views

WP /wp-admin/admin-ajax.php produces 404

Our site has been working fine in the last week. Today, I can't add a new page to our menu. Clicking "Add to Menu" just produces a spinning icon that never disappears. If I look at the Chrome console,...
1
vote
0answers
178 views

Wordpress menu not loading in the admin side appearence-> menu tab

Uncaught ReferenceError: columns is not defined load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,jquery-ui-draggable,...
1
vote
1answer
12 views

Add custom external link to menu

I have added few custom external links to my menu and they all link to 1 website but with a few subfolders, so the urls look pretty much like this: website.co.uk/web1/web2/web3/folder1\folder2\...
1
vote
0answers
53 views

How to add an arrow to menu items has submenus

I want to add arrow (or anything like ...) after every menu item that have children menus. I know that there is some JavaScript solutions. But for some reasons (stability and ...), I don't want to ...
1
vote
1answer
414 views

current-menu-item class in CSS

I have created one main Page(Home Page) and many custom links in wp-admin. All custom links are linked to sections of Home Page. Example: Custom link About Us has a URL = #section1 and in my code I ...
1
vote
1answer
257 views

How to use buttons elements for tgetWordPress menu items?

How do I mix HTML element types for a two-menu navbar? I am building a WordPress theme with Bootstrap 4. WordPress' menu contents should be sourced from the Menus options, output in to a Bootstrap 4 ...
1
vote
1answer
25 views

How to handle many different menus?

I'm developing a site that has about 200-300 pages, that each needs a custom side-menu, linking to primarily internal pages. So here's one sidebar: Link to /foo Link to /bar Link to www.example.org ...
1
vote
1answer
41 views

header menu structure: cannot add additional menu items without alignment issues

When I add a new menu item to the header menu there is an alignment issue (please see the image). I'm not exactly sure which part of the header.php file to modify to address this problem. Update - ...
1
vote
2answers
336 views

wp_nav_menu returns menu list in ascending order. How can I arrange the menu same as dashboard menu

<?php wp_nav_menu(array( 'theme_location' => 'primary', 'container' => 'ul', 'menu_class'=> 'top-menu' ...
1
vote
1answer
34 views

Programmatically add existing pages and subpages to Appearance Menu

I have inherited a site with over 600 pages/subpages. I plan to use a plugin to change the way the navigation displays but it requires the pages to be in the Appearance -> Menu in this page: /wp-admin/...
1
vote
0answers
84 views

Tiles as a navigation

I would like to make a menu in such a way that each item in the menu would be a separate tile (look attachment) It's possible? I have already code: <?php $my_menu = array( 'menu' => '...
1
vote
0answers
684 views

bootstrap menu parent toggle and arrow

I have created a menu in Bootstrap 4: Here is the code: <section class="menuBar"> <nav class="navbar navbar-expand-lg navbar-light" data-toggle="sticky-onscroll"> <div class="...