@BrainiacWebDesigns
No, it’s not a simple edit on any specific page because those are links you’ve added to a WP Custom Menu. As they are stored in the database and called via the wp_nav_menu function, they won’t be visible in any file.
But it looks like it can be done with jquery. 🙂 Assuming you want to continue using WP Custom Menus for those links in your navigation (rather than hard-coding them into your header.php file), you’d need to target only those links contained within the specific <li>
item in the menu. (According to Firebug, that would be .sf-menu li#menu-item-174 li a
. Note that if you modify the custom menu after applying any rules to that specific li#, you may need to adjust the the following code ‘cuz the li# may change.)
jQuery(document).ready(function($) {
$(".sf-menu li#menu-item-174 li a[href^='http://']").attr("target","_blank");
});
To see how it’s done, see the 2nd example snippet on this page: http://css-tricks.com/snippets/jquery/open-external-links-in-new-window/
…as well as wp_enqueue_script: https://codex.wordpress.org/Function_Reference/wp_enqueue_script
Another way would be to use register_nav_menu to create an additional Theme Location under WP Custom Menus where you can assign a special menu coded to open all links in new windows. See the WP codex here for that: https://codex.wordpress.org/Function_Reference/register_nav_menu
Hope this helps 🙂
…and have fun!
u my friend, are a genius. im gonna tackle this right now, thanks buddy
@BrainiacWebDesigns
This code would probably be a lot easier still. You don’t have to worry about any changes to your custom menus because it targets all external links in your main navigation, no matter where they may be in the menu.
jQuery(document).ready(function($) {
$('.sf-menu a:not([href^="http://thesoldiersnetwork.com"]):not([href^="#"]):not([href^="/"])').addClass('external').attr({ target: "_blank" });
});
EDIT: forgot to include.attr({ target: "_blank" })
in the above code… it’s there now 😉
actually i found this plugin…
Open external links in a new window
did exactly what i needed and more in fact! thanks a lot for ur help tho pcwriter!
You’re welcome, glad things worked out
yes sir youre very helpful and its appreciated