Jump to content

Archived

This topic is now archived and is closed to further replies.

eevan79

Simple: open <a href="<php... in new window

Recommended Posts

Hi,

I have simple problem. I want to open php code in new window.

Here is my code:

<li><?php comment_author_link() ?> </li>

How to open this comment_author_link in new window?  :confused:

 

Thanks.

Share this post


Link to post
Share on other sites

Not possible to do unless you modify the wordpress core files, and I'd strongly recommend not doing that

Share this post


Link to post
Share on other sites

Well I didnt think of it til just now but you can do this with a plugin. Create a new file called comment-author-edit.php in the wp-content/plugins/ folder, and put the following in it

<?php

/*
Plugin Name: Edit Comment Author
Version: 0.1
Description: Automatically adds target="_blank" to comment author links
Author: Jay Gilford
Author URI: http://www.jaygilford.com/
Plugin URI: http://www.jaygilford.com/
*/

/* Version Check */
global $wp_version;

$exit_message = 'This plugin requires Wordpress 2.5 or newer. <a href="http://codex.wordpress.org/Upgrading_WordPress">Please Update!</a>';

if(version_compare($wp_version, '2.5', '<')) {
exit($exit_message);
}

/* FILTERS */
add_filter('get_comment_author_link', 'comment_author_link_edit');

function comment_author_link_edit($content) {
    $content = str_replace('<a ', '<a target="_blank"', $content);
    return $content;
}

Save it, then look for Edit Comment Author in your plugin menu in the dashboard, and enable it

Share this post


Link to post
Share on other sites

JAY6390 it works.  ;D

 

Thanks!

 

Regards,

Ivan

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.