Open PHP Link in New Window

A friend asked “In the footer code below I want the <?php wp_loginout(); ?> to open in a new window is there a way to do that?”

I was about to advise him to do this:

<?php echo'<a href="http://..." target=_blank>link here</a>'; ?>

Would this resolve his question?

I have this code:

 <p><?php bloginfo('name'); ?> is powered by <a href=" http://wordpress.org">WordPress</a><a> | </a><?php wp_register('',' or '); ?> <?php wp_loginout(); ?>. <?php wp_meta(); ?></p>

No, it won’t, since there’s no link for him to add a target to, just <?php wp_loginout(); ?>.

What you need to do is add a filter to his theme’s functions.php to alter the output of wp_loginout.

add_filter('loginout', 'somefunc');

This will cause WordPress to call your ‘somefunc’ function whenever wp_loginout() is called, passing it the link HTML as the first parameter.

function somefunc($link) {
  //apply changes to $link html
  return $link;
}

http://codex.wordpress.org/Plugin_API/Filter_Reference#Blog_Information_and_Option_Filters

OK! Thanks for helping me out!

toad78

This is to open a php link in a new window by passing it as HTML. Javascript plugins won’t work for this.

I have the following code on my functions.php page on a Blog:

<?php
add_filter('loginout', 'somefunc');
function somefunc($link) {
  //apply changes to $link html
  return $link;
}
?> 

Could someone give an example of code where the filter & function are used in the functions.php page on Wordpress, as I keep doing it, and it makes my blog page go blank.

Apologies for being a complete novice.

Thank you!