Home > navigation > add a menu item to navigation menu to link to external url

add a menu item to navigation menu to link to external url

July 5Hits:3
Advertisement

I followed this tutorial to add a menu item to navigation menu to link to external site:

http://www.natenewz.com/2009/10/07/hardlink-wordpress-navigation/

I copied the snippet of code to my theme's header.php I created a page with the name having the text that I want to appear in the navigation I added a custom field to the page called redirect and placed the link url into the value field.

And then tested and the link never appears in the menu.

Answers

Are you trying to navigate to an external page or redirect? (Also, bear in mind that was posted almost 3 years ago...in websites and technology in general, that's an eternity!)

You could always just add a custom link to the WordPress menu under Appearance->Menus. Just make sure you add support in the functions.php file.

http://codex.wordpress.org/Appearance_Menus_Screen

And here for adding theme support: http://codex.wordpress.org/Navigation_Menus

This is how you would add functional support:

//setup the dynamic navigation
if (function_exists(register_nav_menus)){
    register_nav_menus(
                 array(
                "main_nav" => "Main Navigation Menu"
                      )
                );
 }

Then go to the admin panel->Appearance->Menus, and add your external link there.

Then in your template, you would call it like so:

<?php wp_nav_menu(array('menu' => 'Main Nav Menu')); ?>

This is, ofcourse, what you were looking for

Tags:navigation

Related Articles

  • add a menu item to navigation menu to link to external urlJuly 5

    I followed this tutorial to add a menu item to navigation menu to link to external site: http://www.natenewz.com/2009/10/07/hardlink-wordpress-navigation/ I copied the snippet of code to my theme's header.php I created a page with the name having the

  • How and where do I programmatically add a menu to the Navigation menu?November 6

    I want to add menu items to the Navigation menu dynamically, depending on certain states (example: user is logged in, etc). I assume I do this in theme_preprocess, but I can't seem to find the var to tweak. Am I looking in the wrong place? Where is t

  • How can I add a caption to my navigation menu?

    How can I add a caption to my navigation menu?March 27

    How can I add a caption to a navigation menu in Drupal 6? I am trying to achieve effect. --------------Solutions------------- function MYTHEME_menu_item_link($link) { // Debug: // dpm($link); // Check menu item localization settings: if (empty($link[

  • how do I delete (not exclude) a menu item from navigation barAugust 5

    I'm building a site's navigation bar programmatically, using the following code: wp_update_nav_menu_item($menu->term_id, 0, array( 'menu-item-title' => $page_data->post_title, 'menu-item-classes' => 'main', 'menu-item-url' => '/', 'menu-ite

  • Add login hyperlink to secondary navigation menu

    Add login hyperlink to secondary navigation menuMarch 7

    I have the following lines of code in my functions.php file: #-----------------------------------------------------------------# # Custom menu #-----------------------------------------------------------------# if ( function_exists( 'register_nav_men

  • Can't add menu items to new menuJuly 15

    I get a message: your configuration has been saved, but when I look at list links it says no links have been added. I found a similar question and tried the answers to no luck. I added a new menu Login Menu which worked fine and shows up with the oth

  • Add a node with its available translations as menu item in main menuDecember 7

    I have the default drupal main menu and i want to add a specific node as parent menu item and its available translations as sub-items (children). When a new translation added i want to be inserted automatically as child menu item. e.g Menu item 1 Men

  • How to Add Active Class to a Navigation Menu Based on URL in each pageJanuary 26

    i have a navigation menu on top of my website .that li's content many pages with different urls. How to Add Active Class to a Navigation Menu Based on URL that in each page display it with a specific color? <ul> <li class="red"><a

  • Custom Nav Menu items default to 'menu-item-type' = 'custom'. How to make a "page" menu item?April 21

    I'm using the code below to create custom menu items on the fly. Its working great, except all menus are created as "Custom". In the code below, setting the menu-item-type to 'page' appears to have no effect. foreach($thePages as $page){ wp_upda

  • Removing all classes from nav_menu except current-menu-item and current-menu-parentOctober 6

    Thanks to Rarst's clever answer, I'm succesfully using these bits to remove the classes from the custom menu markup... add_filter('nav_menu_css_class', 'discard_menu_classes', 10, 2); function discard_menu_classes($classes, $item) { return (array)get

  • Tinymce - How to remove menu items,remove/edit menu headersJanuary 17

    Is it possible to remove menu items in tinymce? Also is it possible to remove an entire dropdown such as 'insert'? --------------Solutions------------- Yes it is possible to remove individual menu items.Please add following code to your tinymce init.

  • Permission for translating menu items via the menu config screenJanuary 31

    I have a multi language Drupal site, Using i18n and the entity translation approach. Translating menu items from an node works well, but not all the menu items are driven by the nodes. Now as user/1, I have permission to translate any menu item from

  • Translating of menu item creates new menu itemFebruary 24

    I have installed these modules concerning menu translation: Entity Translation Menu - entity_translation_i18n_menu Menu Translation - i18n_menu For now, when I translate a menu item, a new - translated menu item is created and I need to set weight an

  • Appearance Menus Screen - menu item drop down menu not functioningAugust 22

    According to WP, there should be options to remove/edit each menu item on a menu under appearance, but this option isn't showing up for me in Chrome or Firefox. I have administrator control of the site and not sure why this isn't working. Suggestions

  • How to add menu items in System menu

    How to add menu items in System menuJanuary 11

    I want to insert an item to System menu: Help and Support About Gnome About Ubuntu More specifically, I want to insert a new item under "About Ubuntu". Trying with alacarte doesn't work. Cloning "ubuntu-about.desktop" file and changing

  • How to add Blender menu item in main menu?

    How to add Blender menu item in main menu?December 1

    Downloaded blender. How can I add menu item with blender icon in main menu? --------------Solutions------------- Before you try to add it to the menu: You should probably install the version of Blender that is available via the Software Centre: Open

  • How to add subtitle for menu items in Nice menu in Drupal 7December 12

    I'm using nice menu in my durpal-7 site.I need to show a subtitle for each menu item.How can this be done ? I'm new to drupal so it would be great if you could help me. --------------Solutions------------- Try OM Maximenu module "Maximize your main n

  • How to add a child item to a menu element (using wp_nav_menu_objects)May 23

    (1) I used the code given on answer to How to use logout function on custom menu link? to programmatically add a menu element to wp_nav_menu_objects (Say "Animals"). I give it an id, say 1000. (2) Similarly, I succesfully created elements that I

  • adding a numbers to a item from navigation menuJuly 5

    I search in Internet but i didn't find a good documented way how to add to item from menu a number , my current menu is like Item1 Item2 Item3 , I'm calculating with WP_Query how many post for category i have , and within function to update a specifi

  • How to hide menu item in navigation from users who have no permissions to view the page?October 22

    I have a menu item in my subsite menu (it is a term driven menu, so managed navigation) that links to a page with unique permissions. Only certain users have been given permissions to see the page and to edit it. Let's say that person X and person Y

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.833 s.