More than one way to say "Read More"?

Community Forums Forums Design Tips and Tricks More than one way to say "Read More"?

This topic is: resolved

This topic contains 17 replies, has 2 voices, and was last updated by  jodzeee 11 months, 3 weeks ago.

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #72885

    jodzeee
    Participant
    Post count: 231

    I’ve modified my Read More link to say “Keep reading…” using this code.

     /** Add the Read more link to excerpts */
    function excerpt_read_more_link($output) {
     global $post;
     return $output . '<a href="'. get_permalink($post->ID) . '" class="read-more-news">Keep reading...</a>';
    }
    add_filter('the_excerpt', 'excerpt_read_more_link');

    http://www.tecadatasafe.com/about-teca-data-safe/news/

    But I’d like it to say “Listen to podcast” on a category page here:

    http://www.tecadatasafe.com/podcast/

    Is that possible?

    #72948

    nutsandbolts
    Keymaster
    Post count: 3202

    You could use a conditional to change the text only on the podcast category:

     /** Add the Read more link to podcast excerpts */
    add_filter( 'the_content_more_link', 'podcast_read_more_link' );
    function podcast_read_more_link() {
        if ( in_category( 'podcast' )) {
       return '<a class="more-link" href="' . get_permalink() . '">Listen to podcast</a>';
      } }

    I tried that out on a test site but let me know if it doesn’t work for you.


    Andrea Whitmer, Owner, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

    #83075

    jodzeee
    Participant
    Post count: 231

    Hi, I’m finally getting back to this. Your code didn’t work for me. I’m using manual excerpts, maybe that’s why? Also, because of this, the excerpts on the slider on my home page have the “keep reading” text/link, but I don’t want it there (I’d manually added it in the excerpt so it’s inline with the text).

    Hope you can help. Thanks!

    #83162

    nutsandbolts
    Keymaster
    Post count: 3202

    I just noticed that your class is different – you might have changed it when you tried my snippet above, but if not, try this one:

     /** Add the Read more link to podcast excerpts */
    add_filter( 'the_content_more_link', 'podcast_read_more_link' );
    function podcast_read_more_link() {
        if ( in_category( 'podcast' )) {
       return '<a class="read-more-news" href="' . get_permalink() . '">Listen to podcast</a>';
      } }

    Andrea Whitmer, Owner, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

    #83186

    jodzeee
    Participant
    Post count: 231

    Changing the class doesn’t help. If I replace my code with that, the read more link doesn’t appear at all. If I add it in addition to my code, there’s no change.

    Is there a way to add a conditional statement to the code I have?

    #83189

    nutsandbolts
    Keymaster
    Post count: 3202

    Okay, try this:

    /** Add the Read more link to podcast excerpts */
    function podcast_read_more_link($output) {
    if ( in_category( 'podcast' )) {
     global $post;
     return $output . '<a href="'. get_permalink($post->ID) . '" class="read-more-news">Listen to podcast</a>';
    } }
    add_filter('the_excerpt', 'podcast_read_more_link');

    Andrea Whitmer, Owner, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

    #83194

    jodzeee
    Participant
    Post count: 231

    That works to make it show up only on the podcasts, but now on the home page and the blog, the entire excerpt disappears (not just the read more link)

    #83195

    nutsandbolts
    Keymaster
    Post count: 3202

    Okay, let’s try this one:

    /** Custom read more links */
    function excerpt_read_more_link($output) {
    if ( in_category( 'podcast' )) {
     global $post;
     return $output . '<a href="'. get_permalink($post->ID) . '" class="read-more-news">Listen to podcast</a>';
    }
    elseif ( !in_category( 'podcast' )) {
     global $post;
     return $output . '<a href="'. get_permalink($post->ID) . '" class="read-more-news">Keep reading...</a>';
    } }
    add_filter('the_excerpt', 'excerpt_read_more_link');

    I haven’t tested that so I have no idea if it will work, but it’s worth a try.


    Andrea Whitmer, Owner, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

    #83197

    jodzeee
    Participant
    Post count: 231

    Oooh, getting closer! Now all I need is to get it off the home page.

    #83198

    nutsandbolts
    Keymaster
    Post count: 3202

    I’m seeing “Keep reading…” on the podcast page. Am I missing something?


    Andrea Whitmer, Owner, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

    #83199

    jodzeee
    Participant
    Post count: 231

    I just purged the cache, try again?

    #83201

    nutsandbolts
    Keymaster
    Post count: 3202

    Okay, awesome! Now what’s showing on the homepage that shouldn’t be?


    Andrea Whitmer, Owner, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

    #83202

    nutsandbolts
    Keymaster
    Post count: 3202

    Oh, I see it. On those widgets, are you using an excerpt? If so, change to content and set a content limit, then remove the keep reading text from the widget. I hope that makes sense.


    Andrea Whitmer, Owner, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

    #83208

    jodzeee
    Participant
    Post count: 231

    Yes, but I need them to be excerpts … the text is an intro that links to a page. I manually added the “more” link in the excerpt.

    #83209

    nutsandbolts
    Keymaster
    Post count: 3202

    I’m not sure I’m understanding… So you need the excerpts there but not the read more link? Or do you want to change the read more link to the custom one?


    Andrea Whitmer, Owner, Nuts and Bolts Media
    I provide dev and training services for web designers • Find me on Twitter and Google+

Viewing 15 posts - 1 through 15 (of 18 total)

You must be logged in to reply to this topic.