add nofollow and _blank target to wordpress author bio

add nofollow and _blank target to wordpress author bio

wordpress seo tips, Here in this article, we shown how to add nofollow and _blank target to wordpress author bio (Biographical Info) section. I am writing blog since 2008. I written on many topics and many blogs. I always accept article from guest author. Some of guest author want to publish their company or personal information in author bio section.

Some months before google changed search engine algorithm. Google look in blog, how many direct out links are used in site. I have many author articles and bio section published in our blogs. We decided to add Nofollow and new tab link attribute in for author bio section.

add nofollow and _blank target to wordpress author bio

If you manually try to add blank target and nofollow for anchor tag. wordpress removes nofollow and target from author bio section using hook.

add nofollow and _blank target to wordpress author bio
add nofollow and _blank target to wordpress author bio

We used simple str_replace method to modify the author bio section.

We created post-author.php file and added following code in that file.

if ( ! function_exists( 'wpapi_post_author' ) ) {

function wpapi_post_author() {

// Only display for standard posts
global $post;
$post_id = $post->ID;
if ( 'post' !== get_post_type($post_id) ) return;

// Vars
$author = get_the_author();
$author_description = get_the_author_meta( 'description' );
$author_description = str_replace('href','rel="nofollow" target="_blank" href', $author_description);
$author_url = esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) );
$author_avatar = get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'wpapi_author_bio_avatar_size', 75 ) );

// Only display if author has a description
if ( !$author_description ) return; ?>

<div class="author-info boxed clr">
<h4 class="heading"><span><?php printf( __( 'Written by %s', 'wpapi' ), $author ); ?></span></h4>
<div class="author-info-inner clr">
<?php if ( $author_avatar ) { ?>
<a href="<?php echo $author_url; ?>" rel="author" class="author-avatar">
<?php echo $author_avatar; ?>
</a>
<?php } ?>
<div class="author-description">
<p><?php echo $author_description; ?></p>
</div><!-- .author-description -->
</div><!-- .author-info-inner -->
</div><!-- .author-info -->

<?php } // End function

} // End if

After this we added following line in functions.php file


// Outputs post author bio
require( get_template_directory() .'/functions/post-author.php' );

If you dont want to create separate file than you can directly add above code in functions.php file.

Above code replace all herf with rel=”nofollow” target=”_blank” href tag. When we add any link in author bio section that will replaced.

This really useful for wordpress website SEO because google will trust URLs in author section.

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

5 thoughts on “add nofollow and _blank target to wordpress author bio”

      1. i have already author php file in theme and i added code you provide in function.php file and add links in author description using dashboard in user profile but not work and links open in same window. i’m using themify basic theme which is free, you can check my site – http://aadityasharma.in/?p=750

        1. Basically following code is important.

          $author = get_the_author();
          $author_description = get_the_author_meta( 'description' );
          $author_description = str_replace('href','rel="nofollow" target="_blank" href', $author_description);

          Above code replacing anchor tag with blank target and rel nofollow. Use correctly in your code. Instead of your author meta you need to use wpapi_post_author() function for displaying author information.

  1. Generally I don’t learn post on blogs, but I wish to say that this
    write-up very compelled me to take a look at and do it!
    Your writing taste has been amazed me. Thank you, very nice post.

Leave a Reply

Your email address will not be published.