Community Forums › Forums › Archived Forums › General Discussion › Customize "continue reading" link on specific pages
Tagged: continue reading
- This topic has 7 replies, 2 voices, and was last updated 8 years, 4 months ago by bionary.
-
AuthorPosts
-
August 5, 2016 at 6:46 am #190771bionaryMember
Hello,
I know you can change the "continue reading" button globally. I am, however looking to do it only on a specific category page. For instance when a user goes to: http://mysite.com/category/videos/ I would like the buttons to say "watch video". Can this be done and hopefully without a plugin?
Thanks!
August 5, 2016 at 7:34 am #190772Genesis DeveloperMemberTry this code once. You will add it in your functions.php file
add_filter( 'get_the_content_more_link', 'gd_customize_more_link_text' ); add_filter( 'excerpt_more', 'gd_customize_more_link_text' ); function gd_customize_more_link_text( $more_link ) { if( ! is_category( 'videos' ) ) return $more_link; $new_more_link = sprintf( '… <a href="%s" class="more-link">%s</a>', get_permalink(), genesis_a11y_more_link( __( 'watch video', 'themeprefix' ) ) ); return $new_more_link; }
August 5, 2016 at 8:14 am #190774bionaryMemberThank you for your efforts but it did not work.
I tried both:
if( ! is_category( 'Videos' ) )
and
if( ! is_category( 'videos' ) )
thinking maybe there could be a difference as one is the category title and the other is the slug...but neither one worked I'm afraid.
August 5, 2016 at 8:25 am #190775Genesis DeveloperMemberThen use the category ID. Assuming your category ID is 20 then you will use
! is_category( 20 )
August 5, 2016 at 8:33 am #190778bionaryMembernope, actually digging into the function.php file I see I already have:
//* Modify the WordPress read more link
add_filter( 'the_content_more_link', 'beautiful_read_more' );
function beautiful_read_more() {
return '' . __( 'Continue Reading', 'beautiful' ) . '';
}//* Modify the content limit read more link add_action( 'genesis_before_loop', 'beautiful_more' ); function beautiful_more() { add_filter( 'get_the_content_more_link', 'beautiful_read_more' ); } add_action( 'genesis_after_loop', 'beautiful_remove_more' ); function beautiful_remove_more() { remove_filter( 'get_the_content_more_link', 'beautiful_read_more' ); }
so i think there's a conflict occurring
August 5, 2016 at 8:40 am #190779Genesis DeveloperMemberAhhh... do not use my code
Try this
add_filter( 'the_content_more_link', 'beautiful_read_more' ); function beautiful_read_more() { if( ! is_category( 'videos' ) ) return __( 'Continue Reading', 'beautiful' ); return __( 'watch video', 'beautiful' ); }
August 5, 2016 at 8:46 am #190780bionaryMemberdid so, with three variants: "videos" "Videos", 18 ... video page comes back with no links
August 5, 2016 at 9:14 am #190781bionaryMemberno, I'm a bozo. your code was working....I just didn't see the 'watch video' only because it wasn't a link...it was simply appended to the end of the text. Here's my final working code:
add_filter( 'the_content_more_link', 'beautiful_read_more' ); function beautiful_read_more() { if(is_category('videos')){ return '<a class="more-link" href="' . get_permalink() . '">' . __( 'Watch Video', 'beautiful' ) . '</a>'; }else{ return '<a class="more-link" href="' . get_permalink() . '">' . __( 'Continue Reading', 'beautiful' ) . '</a>'; } }
Thanks, as i couldn't have done this without your speed help!
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.