308 posts
  • Has referred 1+ members
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+4 more
brainbuzzmedia says

Hey guys

I’ve been trying to add a custom link for when a user uses the_excerpt so that it looks the same as the <!-more-> tag, and I just can’t seem to get rid of the default link that wordpress adds which looks like this: Continue reading ?.

I can get my custom button to show up but it just shows both.

Here is what I added to functions.php:

/** Returns a "Continue Reading" link **/

function my_continue_reading_link() {
  return '<br /><a href="'.get_permalink().'" class="more-link">'
    .__('<span>Continue Reading</span>')
    .'</a>';
}

/** Adds custom "Continue Reading" link to custom post excerpts **/

function my_custom_excerpt_more($output) {
  if (has_excerpt() && !is_attachment()) {
    $output.=my_continue_reading_link();
  }
  return $output;
}
add_filter('get_the_excerpt', 'my_custom_excerpt_more' );
2445 posts
  • Has referred 100+ members
  • Has sold $100+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+3 more
digitalimpact says

Have you tried adding the filter on the_excerpt itself?

add_filter('the_excerpt', 'my_custom_excerpt_more' );

As far as I understand, get_the_excerpt only returns it, but does not manipulate the output in any way. I might be wrong though… Try it and let us know :)

2057 posts
  • Has collected 50+ items on Envato Market
  • Has been part of the Envato Community for over 4 years
  • Sells items exclusively on Envato Market
  • Located in United States
Landonw says
function new_excerpt_more($more) {
    return '[.....]';
}
add_filter('excerpt_more', 'new_excerpt_more');

excerpt_more is what you’re looking for.

308 posts
  • Has referred 1+ members
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+4 more
brainbuzzmedia says

I tried it on “the_excerpt” instead of “get_the_excerpt” and it did the same thing. I also tried using “excerpt_more” but that didn’t seem to do anything at all. Are you sure that that doesn’t just work for whenever you are using the_excerpt instead of the_content and do not have anything entered into the excerpt field in the post?

by
by
by
by
by
by