Add an item to the top-menu
-
I’d like to add an additional item/field (just a text with a hyperlink) at the top of my blog, in the
menu-top
, where pages links are located.I added a new filter to my theme
functions.php
file:add_filter('wp_nav_menu_nav', 'add_admin_link', 10, 2); function add_admin_link($items, $args){ if( $args->theme_location == 'primary' ){ $items .= '<li><a title="Admin" href="'. esc_url( admin_url() ) .'">' . __( 'Admin' ) . '</a></li>'; } return $items; }
I’m supposing it must be the “primary” location as this is a value passed to this menu from my
header.php
:<?php wp_nav_menu( array( 'theme_location' => 'primary', ...
But it won’t display text and link.
If remove the
if( $args->theme_location == 'primary' )
condition – the text and link are displayed but on the right-column instead of top of the page.What I’m doing wrong here?
P.S. I’m not a PHP-developer.
The page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Add an item to the top-menu’ is closed to new replies.