WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Comment Author Link in New Window (2 posts)

  1. andrewkhunn
    Member
    Posted 4 years ago #

    I was wondering if someone with better PHP-fu than me could help me craft a filter for functions.php to alter get_comment_author_link to open in a new window?

    My (likely horrible) best guess follows:

    function get_comment_author_link_new() {
    
    	$url = get_comment_author_url();
    	$author = get_comment_author();
    
    	if (empty( $url ) || 'http://' == $url)
    
    		$return = $author;
    
    	else
    
    		$return = "<a href='$url' rel='external nofollow' class='url' target='_blank'>$author</a>";
    
    	return apply_filters('get_comment_author_link_new', $return);
    
    }
    
    add_filter('get_comment_author_link', 'get_comment_author_link_new');
  2. andrewkhunn
    Member
    Posted 4 years ago #

    Solved. I just needed to change:

    return apply_filters('get_comment_author_link_new', $return);

    to

    return $return;

Topic Closed

This topic has been closed to new replies.

About this Topic