WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [closed] Add "target" element to Menu Editor (20 posts)

  1. scallas
    Member
    Posted 3 years ago #

    At least for custom links, it would be great to allow menu options to open in a new window/tab via the target="_blank" element in the link tags. Controlling menus in the WP Menu tool is awesome, but many of the sites I work with have external links in the main navigation menus that need to open in a new tab.

    Thanks!
    scallas

  2. I think you can cheat this by making your link:

    hhtp://domain.com/page" _target="blank

    Don't know how you'd do it for pages, though, but that should work.

  3. scallas
    Member
    Posted 3 years ago #

    Interesting. Looks like it could work. Will try that out.

    Thanks!

  4. christopherross
    Member
    Posted 3 years ago #

    You could also do:

    $menu = wp_nav_menu('echo=false&menu=Footer');
    $menu = str_replace('<a',"<a target='_blank'",$menu);
    echo $menu;

    In your theme.

  5. scallas
    Member
    Posted 3 years ago #

    @Ipstenu - the form cleans up the quotes - and won't recognize the html entities. Have not tried christopher's suggestion. Would like to stay out of the theme, if I could. Clients will not be getting into the them, by any means.

    Doesn't seem like a stretch that this would be useful to a larger audience than just myself. My vote would be to add it to the Menu manager - even if it only showed up in the Custom Links dialog.

    Thanks for the input!

  6. Hmm. Maybe this?

    http://wordpress.org/extend/plugins/quick-pagepost-redirect-plugin/

    Honestly, using the target method isn't considered user friendly anyway. People know how to open in a new window if they want to.

  7. alex chousmith
    Member
    Posted 3 years ago #

    Only after lots and lots of snooping around did I find this one

    On /wp-admin/nav-menus.php , click on the link for Screen Options in the top right of your screen. Hidden away in the dropdown there, below the usual Show on screen checkboxes, is another line of Show advanced menu properties checkboxes.

    Just check the box for Link Target and then all your Menu Items will have the additional option of Link Target : "Same window or tab" or "New window or tab"

  8. scallas
    Member
    Posted 3 years ago #

    Alex, you make my short list of WordPress heros. This sure seemed like a major oversight. I was having a hard time believing that there wasn't some way around it. Of course, it had to be so simple!

    Thanks!
    Scott

  9. Shaytoon5959
    Member
    Posted 3 years ago #

    alex chousmith
    GENIUS!

  10. jcranny
    Member
    Posted 3 years ago #

    Hidden Gem!

  11. jzahlaway
    Member
    Posted 3 years ago #

    I'm not ashamed to say it: I love Alex Chousmith right now.

  12. sdoss
    Member
    Posted 3 years ago #

    I'm with jzahlaway. Thanks, Alex.

  13. JamesBB
    Member
    Posted 3 years ago #

    Woowww I was looking for a solution to this for quite a while too!
    Well Alex, your very correct answer worked perfect!
    A big THANKS to you!!!

  14. zerbe
    Member
    Posted 2 years ago #

    Good stuff alex chousmith -- "man crush'. I want it to be a default feature, but respect its Screen Options status. Touché WordPress!

    To help people find this: WordPress Menu, target="_blank", _blank, new window, menu

  15. Kat Crane
    Member
    Posted 2 years ago #

    Dear Alex Chousmith - will you marry me???? Your answer was just what I was looking for. You're the kat's pajamas. mrrrowww!!! =^..^=

  16. elijabaley
    Member
    Posted 2 years ago #

    GENIUS:
    I had the same problem, you are the "Egg of Columbus" discoverer

  17. rbellerose
    Member
    Posted 2 years ago #

    I can't believe it was that easy, hero is an understatement.

  18. boldadvertising
    Member
    Posted 2 years ago #

    Thanks Alex!

  19. zounds
    Member
    Posted 2 years ago #

    Cheers Alex - saved me plenty of frustration, I'd never have dreamt of looking there again (I'd clicked on screen options once before elsewhere and it only had an accesibility option).

    Thanks!

  20. kaheidt
    Member
    Posted 2 years ago #

    9 months later, and you're still friggin awesome.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.