Plugin / Auto-hyperlink URLs

Scott Reilly



Automatically turns plaintext URLs and email addresses into links.

This plugin seeks to replace and extend WordPress’s default auto-hyperlinking function. This plugin uses different pattern matching expressions than the WordPress default in order to prevent inappropriate adjacent characters from becoming part of the link (as WordPress has improved over the years, nowadays this is just a few edge cases like text links that are braced or bracketed) and it prevents invalid URIs (i.e. http://blah) from becoming links.

More significantly, this plugin adds configurability to the auto-hyperlinker such that you can configure:

  • If you want text URLs to only show the hostname
  • If you want text URLs truncated after N characters
  • If you want auto-hyperlinked URLs to open in new browser window or not
  • If you want the URI scheme (i.e. “http://”) to be stripped for displayed links
  • The text to come before and after the link text for truncated links
  • If you want rel=”nofollow” to be supported
  • If you wish to support additional domain extensions not already configured into the plugin
  • If you want certain domains to be omitted from auto-linking

This plugin will recognize any explicit URI scheme (http|https|ftp|news)://, etc, as well as email addresses. It also adds the new ability to recognize Class B domain references (i.e. “”, not just domains prepended with “www.”) as valid links (i.e. “” would get auto-hyperlinked)

The following domain extensions (aka TLDs, Top-Level Domains) are recognized by the plugin: com, org, net, gov, edu, mil, us, info, biz, ws, name, mobi, cc, tv. These only comes into play when you have a plaintext URL that does not have an explicit URI scheme specified. If you need support for additional TLDs, you can add more via the plugin’s admin options page or via filter.

This plugin also activates auto-hyperlinking of text links within post/page content.

Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage


(when running with default configuration):

To better illustrate what results you might get using the various settings above, here are examples.

For the following, assume the following URL is appearing as plaintext in a post:

And unless explicitly stated, the results are using default values (nofollow is false, hyperlink emails is true, Hyperlink Mode is 0)


The plugin exposes seven filters for hooking. Typically, customizations utilizing these hooks would be put into your active theme’s functions.php file, or used by another plugin.

c2c_autohyperlink_urls_filters (filter)

This hook allows you to customize which filters get processed by the plugin.


  • $filters (array): The filters whose text should be auto-hyperlinked. Default array( 'the_content', 'the_excerpt', 'widget_text' ).


 * Auto-hyperlink additional filters.
 * @param array $filters
 * @return array
function my_c2c_autohyperlink_urls_filters( $filters ) {
    // Add in another filter to process.
    $filters[] = 'my_custom_filter';
    return $filters;
add_filter( 'c2c_autohyperlink_urls_filters', 'my_c2c_autohyperlink_urls_filters' );

autohyperlink_urls_class (filter)

This hook allows you to customize the class added to links created by the plugin.


  • $class (string): The class name. Default ‘autohyperlink’.


// Set default class for links added by Auto-hyperlink URLs.
add_filter( 'autohyperlink_urls_class', function ( $class ) { return 'myclass'; } );

autohyperlink_urls_link_attributes (filter)

This hook allows you to add custom attributes to links created by the plugin.


  • $attributes (array): The link attributes already created by the plugin.
  • $context (string): The context for the link. Either ‘url’ or ’email’. Default ‘url’.
  • $title (string): The text for the link’s title attribute.


 * Output 'title' attribute for link, as done by plugin prior to v5.0.
 * @param array  $attributes The attributes for the link tag.
 * @param string $context    The context for the link. Either 'url' or 'email'. Default 'url'.
 * @param string $title      The text for the link's title attribute.
 * @return array
function add_title_attribute_for_autohyperlink_urls( $attributes, $context = 'url', $title = '' ) {
    if ( $title ) {
        $attributes['title'] = $title;

    return $attributes;
add_filter( 'autohyperlink_urls_link_attributes', 'add_title_attribute_for_autohyperlink_urls', 10, 3 );

autohyperlink_urls_tlds (filter)

This hook allows you to custom the list of supported TLDs for non-URI scheme link auto-hyperlinking. Note that the value sent to the hook includes the default TLDs plus those added via the ‘more_extensions’ setting. Also note that the TLDs are defined as a ‘|’-separated string.


  • $tlds (string): The supported TLDs. Default 'com|org|net|gov|edu|mil|us|info|biz|ws|name|mobi|cc|tv'.


// Add support for more TLDs.
add_filter( 'autohyperlink_urls_tlds', function ( $tlds ) { return $tlds . '|in|io|tt'; } );

autohyperlink_urls_truncate_link (filter)

This hook allows you to custom how truncated links are displayed.


  • $url (string): The potentially truncated URL.
  • $original_url (string): The full, original URL.
  • $context (string): The context for the link. Either ‘url’ or ’email’. Default ‘url’.

autohyperlink_urls_custom_exclusions (filter)

This hook allows you to define custom logic to determine if a link should be hyperlinked.


  • $should (bool): Should the link be hyperlinked? Default true.
  • $url (string): The full URL.
  • $domain (string): Just the domain/host part of the URL.


 * Don't hyperlink links on the front page.
 * @param  bool   $should
 * @param  string $url
 * @param  string $domain
 * @return bool
function my_autohyperlink_urls_custom_exclusions( $should, $url, $domain ) {
    if ( is_front_page() ) {
        return false;
    } else {
        return $should;
add_filter( 'autohyperlink_urls_custom_exclusions', 'my_autohyperlink_urls_custom_exclusions' );

autohyperlink_urls_exclude_domains (filter)

This hook allows you to specify domains that should not get auto-hyperlinked. Note that the value sent to the hook includes the value of the ‘exclude_domains’ setting. Note that only the domain (without URI scheme or trailing slash) should be specified.


  • $excluded_domains (array): The domains already being excluded. Default empty array.


 * Exclude certain domains from being auto-hyperlinked.
 * @param  array $excluded_domains
 * @return array
function my_autohyperlink_urls_exclude_domains( $excluded_domains ) {
    $excluded_domains[] = '';
    $excluded_domains[] = '';
    return $excluded_domains;
add_filter( 'autohyperlink_urls_exclude_domains', 'my_autohyperlink_urls_exclude_domains' );


8 reviews

Rating breakdown

Details Information



First Released

21 Dec, 2004

Total Downloads


Wordpress Version

4.7 or higher

Tested up to:


Require PHP Version:





The plugin hasn't been transalated in any language other than English.


The information provided in this THEME/PLUGIN DIRECTORY is made available for information purposes only, and intended to serve as a resource to enable visitors to select a relevant theme or plugin. wpSocket gives no warranty of any kind, express or implied with regard to the information, including without limitation any warranty that the particular theme or plugin that you select is qualified on your situation.

The information in the individual theme or plugin displayed in the Directory is provided by the owners and contributors themselves. wpSocket gives no warranty as to the accuracy of the information and will not be liable to you for any loss or damage suffered by you as a consequence of your reliance on the information.

Links to respective sites are offered to assist in accessing additional information. The links may be outdated or broken. Connect to outside sites at your own risk. The Theme/Plugin Directory does not endorse the content or accuracy of any listing or external website.

While information is made available, no guarantee is given that the details provided are correct, complete or up-to-date.

wpSocket is not related to the theme or plugin, and also not responsible and expressly disclaims all liability for, damages of any kind, arising out of the use, reference to, or reliance on, any information or business listed throughout our site.

Keep Leading Your Followers!
Share it for them.