[resolved] Shorten long hyperlinks in comments (4 posts)

  1. ChillPenguin
    Posted 9 years ago #

    I'm trying to find a way to automatically shorten long hyperlinks that are posted in the comments. For example, turn something like:


    into something like:


    Currently, I have a design that is far too thin, which causes even moderately long hyperlinks to break the design. Making any changes to the design is not an option, so I am looking for a code solution.

    Any ideas? Thanks in advance.

  2. The trick is in the make_clickable function. This filter is what converts the non-links into links. So to make it act differently, you just have to modify it to replace the links with shorter bits.

    However, modifying core code is no good either, so the better way is to clone the function, and modify the clone. Then you can plug it in where you want it. In your case, in comment text.

    Here's a quick hack I did of the function. It's untested, but I think it'll work.

    You'd put that code into your theme (like functions.php) or into your my-hacks file, or into a plugin.

  3. moshu
    Posted 9 years ago #

    CP, see also this thread:
    (found by search, BTW...)

  4. ChillPenguin
    Posted 9 years ago #

    Searching is my friend :)

    Thanks for the replies guys. I just came back to say that this plugin was able to meet my needs (listed in the codex):


    The solution couldn't be simpler. Thanks again!

Topic Closed

This topic has been closed to new replies.

About this Topic