Home > Blog : Tips > Add nofollow Attribute Value to Read More Link

Add nofollow Attribute Value to Read More Link

July 17th, 2010 zoom in zoom out Leave a comment Translate

Sometimes if you write article in your wordpress blog, you might using more tag to separate the teaser and the main content. If you check to the source of your read more link, automatically it doesn’t have a rel attribute. The left picture show you the appear of the more tag on wordpress. This tag is called by the the_content('Read more...') function.

I have search how to insert additional rel attribute from the theme’s file, but didn’t found any solution. So the alternative way is to hack the core file of the wordpress engine. :D For your information when you call more tag actually you also call the function get_the_content that actually is stored in post-template.php located in wp-includes directory.

After you find and open your post-template.php file, search for the get_the_content function, there you’ll see this line:

$output .= ' <a href="'. get_permalink() . "#more-$id\">$more_link_text</a>";

Edit that line by adding a rel attribute:

$output .= ' <a href="'. get_permalink() . "#more-$id\" class=\"more-link\"  rel=\"nofollow\">$more_link_text</a>";

Save it and done. I believe this is one of the many ways to add a nofollow attribe value to the read more link on WordPress engine

Categories: Tips Tags: , 7,183 views

Another Posts That Maybe Related

  1. July 17th, 2010 at 10:13 | #1

    yang edit di theme nya ga ada ya?
    berarti jika kita upgrade WP, ‘post-template.php’ perLu dirubah lagi?

  2. July 17th, 2010 at 16:48 | #2

    @Hari Mulya
    sebenarnya ada cara lain sih.. (macgyver mode: on) :razz:
    yaitu dengan memakai fungsi the_excerpt() nah trus link read more nya pake get_permalink() trus tambahkan string #more- tambah lagi fungsi the_id()

    nah, pemanggilannya kurang lebih akan terlihat seperti ini:

    <?php if (have_posts()) : while (have_posts()) : the_post(); //begin The Loop ?>
    <?php the_excerpt(); ?>
    <p><a rel="nofollow" title="Continue reading <?php the_title(); ?>" href="<?php the_permalink() ?>#more-<?php the_ID() ?>" class="more-link">Read more...</a></p>
    <?php endwhile; //end of The Loop ?>