Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Page & Category Menu Bars (http://forum.bytesforall.com/forumdisplay.php?f=10)
-   -   [SOLVED] External links in new window (http://forum.bytesforall.com/showthread.php?t=4221)

Nickp Nov 5, 2009 01:58 AM

[SOLVED] External links in new window
 
I have created a page menu bar which lists all the pages in the blog/site. I want to add a further item to the menu to link to an external site, and I want that link to open in a new window/tab.

I have created a page called "External" and I have modified functions.php to pick up the link to the "External" page and present "http://www.external.com" instead. This works just fine. How do I get this external link to open in a new window? Where do I go to add the "target=_blank"?

I have tried editing functions.php like this:
Quote:

<?php function replace_menu_link($string) {
return str_replace('\"http://mydomain/wordpress/external\"',
'\"http://www.external.com/\" target=_\"blank\"' , $string);
}
but this just loses the link altogether. (I may have escaped the quotes wrong though...)

I am happy for all external links on the menu to open in a new window/tab.

Other plugins I have tried:
* Redirector - means I don't have to edit functions.php and works ok; no new window though
* Identify external links - this works ok on the content of a post but doesn't pick up changes made by Redirector or code changes in functions.php

Is there a plugin that will work with Atahualpa, or do I need to dig further into the code in functions.php?

Sorry if there's a thread on this already, I thought I'd searched enough! Please point me to it if there is one!

Nickp Nov 5, 2009 03:19 AM

This plugin does the trick:
http://txfx.net/wordpress-plugins/page-links-to/


All times are GMT -6. The time now is 04:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.