How to make “more” or “continue reading” links on excerpts nofollow?

I tried to make each one of my post excerpt’s link to the full post “nofollow” like this:

<a href="<?php the_permalink() ?>" rel="nofollow">&rarr; Continue Reading</a>

However, that doesn’t seem to work. I’m pretty new to WP / PHP, so what do I need to do?

Related posts

Leave a Reply

1 comment

  1. In your theme’s functions.php:

    /* Returns a "Continue Reading" link for excerpts, with 'nofollow' set */
    function your_theme_continue_reading_link() {
        return ' <a href="'. get_permalink() . '" rel="nofollow">' .
            '<span class="meta-nav">&rarr;</span> Continue reading</a>';
    }
    /* Replaces "[...]" (appended to automatically generated excerpts) */
    function your_theme_auto_excerpt_more( $more ) {
        return ' &hellip;' . your_theme_continue_reading_link();
    }
    add_filter( 'excerpt_more', 'your_theme_auto_excerpt_more' );