Community Forums › Forums › Archived Forums › Design Tips and Tricks › More than one way to say "Read More"?
- This topic has 17 replies, 2 voices, and was last updated 11 years ago by jodzeee.
-
AuthorPosts
-
November 13, 2013 at 11:36 pm #72885jodzeeeMember
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?
November 14, 2013 at 10:09 am #72948nutsandboltsMemberYou 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/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+January 4, 2014 at 1:05 am #83075jodzeeeMemberHi, 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!
January 4, 2014 at 10:55 am #83162nutsandboltsMemberI 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/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+January 4, 2014 at 11:28 am #83186jodzeeeMemberChanging 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?
January 4, 2014 at 11:30 am #83189nutsandboltsMemberOkay, 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/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+January 4, 2014 at 12:06 pm #83194jodzeeeMemberThat 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)
January 4, 2014 at 12:08 pm #83195nutsandboltsMemberOkay, 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/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+January 4, 2014 at 12:12 pm #83197jodzeeeMemberOooh, getting closer! Now all I need is to get it off the home page.
January 4, 2014 at 12:13 pm #83198nutsandboltsMemberI'm seeing "Keep reading..." on the podcast page. Am I missing something?
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+January 4, 2014 at 12:15 pm #83199jodzeeeMemberI just purged the cache, try again?
January 4, 2014 at 12:16 pm #83201nutsandboltsMemberOkay, awesome! Now what's showing on the homepage that shouldn't be?
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+January 4, 2014 at 12:17 pm #83202nutsandboltsMemberOh, 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/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+January 4, 2014 at 12:24 pm #83208jodzeeeMemberYes, 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.
January 4, 2014 at 12:26 pm #83209nutsandboltsMemberI'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/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+January 4, 2014 at 12:34 pm #83211jodzeeeMemberWhen I originally created the site, there was no blog or podcasts. I had manually added the "more" link to the excerpts on the home page and that's all I needed. Then later, when the podcasts and blog were added, I added code for the read more link for those, but it then appeared on the home page slider excerpts as well.
I could remove the manual link, but then I'd need another custom one that says "more" and I'd need it to be inline instead of under the excerpt (is that possible?).
But I found an easier solution ... I hid it in the CSS!
January 4, 2014 at 12:35 pm #83212nutsandboltsMemberHAHAHAHA, whatever works! Glad you found a solution. 🙂
I'm going to mark this topic as resolved but feel free to open a new one if you need help with anything else.
Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
I provide development and training services for designers • Find me on Twitter and Google+January 4, 2014 at 12:36 pm #83213jodzeeeMemberThank you soooooooooo much for your help! I appreciate the patience and perseverance!
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.