Ready to get started?Download WordPress


Make ... in [...] clickable (6 posts)

  1. essdub
    Posted 6 years ago #

    Can the ... in an excerpt be made clickable? As in, I'd like the ... in the [...] at the end of an excerpt to link to that post's permalink. I looked in the codex but didn't see any description of how to alter the actual excerpt. I'm also assuming I missed something there as well.

    If someone could either point me to the right article or assist here, that'd be super. Thanks!

  2. wp_guy
    Posted 6 years ago #

    Adding the following code to the functions.php of your theme should do the trick:

    function clickable_ellipsis($content){
    	$searchfor = '/\[(…)\]/';
    	$replacewith = '[<a href="'.get_permalink().'">$1</a>]';
    	$content = preg_replace($searchfor, $replacewith, $content);
    	return $content;
    add_filter('the_excerpt', 'clickable_ellipsis');
  3. essdub
    Posted 6 years ago #

    Hmm. No dice. I plugged in your code just above another function (and made sure we have three periods in there and not that funky character that shows up in your code) but my ... are still just ... and not clickable. You can see it at the bottom of this page: http://epicmcc.org

  4. 4k
    Posted 6 years ago #

  5. wp_guy
    Posted 6 years ago #

    yay... the funky character you mention is supposed to be an ellipsis character which is different from three points "& # 8 2 3 0 ;" without the spaces... I'm unable to paste it here without it converting to the actual ellipsis...

    Like this:


  6. wp_guy
    Posted 6 years ago #

    Maybe it'll be easier to use 4k's suggested plugin... your call ;-)

Topic Closed

This topic has been closed to new replies.

About this Topic