Quick Tip: replacing URLs in post excerpts

image_pdfimage_print

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 runs Transmit Studio, a media creation lab in San José. He's built more websites with WordPress than he can remember. He likes hearing himself talk and writing about himself in third person.

Leave a Comment