Quick Tip: replacing URLs in post excerpts

I generally find WordPress excerpts a little bit irritating. They ignore all formatting, including paragraphs, so you just end up with a block of text with no styling and sometimes little sense.

To make matters worse, if your content includes a URL you’ll end up with the whole thing displayed in the excerpt, no matter how long or nonsensical it looks. Luckily, this is easily remedied with a little code.

Drop the code below into your functions.php file and those URLs will be stripped out of the excerpt:

stuff we dig

FYI: yes, the above are affiliate links, so we do make a small amount of money if you follow them over and buy what they're selling. Thank you for helping pay our hosting costs!

Dave Kuhar

Dave ran his own business, Transmit Studio, a media creation lab in San José, for 21 years. He's built more websites than he can remember with WordPress. He now works for a much larger WordPress-focused company and enjoys having someone else in charge of the books. He likes hearing himself talk and writing about himself in third person.

Leave a Comment