treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] Wordpress- How to link a main nav to an external link?

  • Title pretty much says it all. I have a main nav item (a page created to create the nav) but I want it to link externally. How would I do that?
  • What version of WP and theme are you using?
  • Exactly what do you mean, link externally? As in, link to for example Google? I must not understanding this question, but can't you just do it like:
    <a href="http://www.google.com">Click here for an external link</a>
  • I'm using a custom theme.

    @bob, I can't just put a link there, the links are generated by created pages.
  • There is a plugin called, LJ Custom Menu Links, that will take care of that for you. Create a page with the name you want and fill in the link at the bottom. It will allow you to move it in the menu easily.
  • Thanks for the suggestion. I'll try it out when i get home and give an update then
  • Noah, use WP Menubar. It is incredibly flexible and will allow you to do exactly what you are asking for, and much more.

    http://wordpress.org/extend/plugins/menubar/
    http://www.blogsweek.com/wp-menubar-3-documentation/
  • Could you paste the nav's php? - Perhaps I can see what's going on there :p
  • <?php


    if (is_home()) {

    $addclass = ' class="current_page_item"';

    } else {

    $addclass = '';

    }

    wp_list_pages('sort_column=menu_order&title_li=');
    ?>


    This is my nav's php
  • That spits out <li> elements. So this should work:
    <?php


    if (is_home()) {

    $addclass = ' class="current_page_item"';

    } else {

    $addclass = '';

    }

    wp_list_pages('sort_column=menu_order&title_li=');
    ?>
    <li><a href="#">Example</a></li>
  • Yeah. I know I could do that but that would put it at the end and I need it third from last. If I go to the admin panel to order the links, can I order them around it?
  • The links can be arranged in any order through the admin panel (Wordpress 3) - Even external links. However the theme has to support it.

    Or what about:
    <?php


    if (is_home()) {

    $addclass = ' class="current_page_item"';

    } else {

    $addclass = '';

    }

    wp_list_pages('sort_column=menu_order&title_li=&exclude=344,655,777');
    ?>
    <li><a href="#">Example</a></li>
    <?php wp_list_pages('sort_column=menu_order&title_li=&include=344,655,777'); ?>
  • The first loop excludes the three posts, the second includes them, but doesn't that second one also include all the ones in the first loop as well? You'd be duplicated nav links right?

    I suppose if worse comes to worse I can just take out the loops and just put in hard code list items.
  • I would edit the theme and enable the Wordpress 3 menu editor. (I haven't actually gone through that tutorial, I just googled it quickly)
  • Well, there have definitely been several suggestions that can get the desired affect so I'll mark this as solved