Need "learn more" link in post excerpt

Community Forums Forums General Discussion Need "learn more" link in post excerpt

This topic is: not resolved

This topic contains 5 replies, has 2 voices, and was last updated by  Debra Scott 9 months, 4 weeks ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #46464

    streetfire
    Participant
    Post count: 9

    I am using the Eleven 40 theme and would like to have a “Learn More” link in the post excerpt. I manually put in <a href> code and grabbed the post link, but it seems there should be a much easier way to build this in without having to manually copy / paste code and grab the post link for each item. Please advise, thanks!

    #46509

    Debra Scott
    Moderator
    Post count: 132

    You can modify the read more link with custom code http://my.studiopress.com/snippets/post-excerpts/#content-more-link


    need help with your business or personal website? Contact me at Fat Cat Designs

    #46539

    streetfire
    Participant
    Post count: 9

    Hi, I looked at that link previously, but it doesn’t seem to apply when using the post excerpt rather than content. There’s not even a link to  ”modify” right now. I need to add one to the archive pages.

    • This reply was modified 10 months ago by  streetfire.
    • This reply was modified 10 months ago by  streetfire.
    #46618

    Debra Scott
    Moderator
    Post count: 132

    try this then:

    // Replaces the excerpt "more" text by a link
    function new_excerpt_more($more) {
           global $post;
    	return '<a class="moretag" href="'. get_permalink($post->ID) . '"> Read the full article...</a>';
    }
    add_filter('excerpt_more', 'new_excerpt_more');

    you can find codes like this here
    http://codex.wordpress.org/


    need help with your business or personal website? Contact me at Fat Cat Designs

    #47089

    streetfire
    Participant
    Post count: 9

    Thanks you for the help. I pasted that into functions.php in my child theme, but it didn’t help. Any other suggestions?

    #47098

    Debra Scott
    Moderator
    Post count: 132

    it didn’t help in what way? it didn’t take away the ellipsis or it didn’t have your desired text?

    I’m guessing the former since I gave you the wrong code.. sorry about that

    function replace_excerpt($content) {
           return str_replace('[...]',
                   '... <div class="more-link"><a>Continue Reading</a></div>',
                   $content
           );
    }
    add_filter('the_excerpt', 'replace_excerpt');

    need help with your business or personal website? Contact me at Fat Cat Designs

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.