Tag: wordpress

Make Link to Comment Author Opens in New Window

Just open and edit your comment-template.php inside the wp-includes folder. Search the file’s source code until you find the function get_comment_author_link as below;

function get_comment_author_link( $comment_ID = 0 ) {
	$comment = get_comment( $comment_ID );
	$url     = get_comment_author_url( $comment );
	$author  = get_comment_author( $comment );

	if ( empty( $url ) || 'http://' == $url )
		$return = $author;
	else
		$return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";

	return apply_filters( 'get_comment_author_link', $return, $author, $comment->comment_ID );
}

Now you only need to add target='_blank' inside the link tag, of the second $return variable;

$return = "<a href='$url' rel='external nofollow' target='_blank'>$author</a>";

Save the file and upload it to the wp-includes folder.

Exclude Certain Category Posts From the Blog Page

The correct way to exclude categories from main blog page, is to make use of pre_get_posts which change the query variable before the main query is executed. The following is an example;

function exclude_category($query) {
    if ($query->is_home() && $query->is_main_query()) {
        $query->set('cat', '-3,-6');
    }
}
add_action('pre_get_posts', 'exclude_category');

For the full list of available parameters you can use with pre_get_posts, please visit WP_Query codex page.