307 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Exclusive Author
  • Envato Studio (Microlancer) Beta Tester
  • United States
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Referred between 1 and 9 users
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' );
2441 posts
  • Has been a member for 5-6 years
  • Exclusive Author
  • Europe
  • Bought between 10 and 49 items
  • Referred between 100 and 199 users
  • Sold between 100 and 1 000 dollars
  • Envato Studio (Microlancer) Beta Tester
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 :)

2054 posts
  • Has been a member for 4-5 years
  • Bought between 50 and 99 items
  • Exclusive Author
  • 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.

307 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Exclusive Author
  • Envato Studio (Microlancer) Beta Tester
  • United States
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Referred between 1 and 9 users
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