WordPress.org

Plugin Directory

WP External Links (nofollow new tab seo)

Open external links in a new tab / window, add "nofollow", "noopener" and font icons, SEO and more. Also for internal links.

I want certain posts or pages to be ignored by the plugin. How?

By using the wpel_apply_settings filter you can stop the plugin from processing that page, f.e.:

add_action( 'wpel_apply_settings', function () {
    global $post;
    $ignored_post_ids = array( 1, 2, 4 );

    if ( in_array( $post->ID, $ignored_post_ids ) ) {
        return false;
    }

    return true;
}, 10 );

Using this filter you can ignore any request, like certain category, archive etcetera.

I want specific links to be ignored by the plugin. How?

By using the wpel_before_apply_link filter you can skip specific links from being processed by WPEL plugin, f.e.:

add_action( 'wpel_before_apply_link', function ( $link ) {
    // ignore links with class "some-cls"
    if ( $link->has_attr_value( 'class', 'some-cls' ) ) {
        $link->set_ignore();
    }
}, 10 );

How to create a redirect for external links? (f.e. affiliate links)

Create redirect by using the wpel_link action. Add some code to functions.php of your theme, like:

add_action( 'wpel_link', function ( $link ) {
    // check if link is an external links
    if ( $link->is_external() ) {
        // get current url
        $url = $link->get_attr( 'href' );

        // set redirect url
        $redirect_url = '//somedom.com?url='. urlencode( $url );
        $link->set_attr( 'href', $redirect_url );
    }
}, 10, 1 );

How to open external links in a new popup window?

By adding this JavaScript code to your site:

jQuery(function ($) {

    $('a[data-wpel-link="external"]').click(function (e) {
        // open link in popup window
        window.open($(this).attr('href'), '_blank', 'width=800, height=600');

        // stop default and other behaviour
        e.preventDefault();
        e.stopImmediatePropagation();
    });

});

See more information on the window.open() method.

How to add an confirm (or alert) when opening external links?

Add this JavaScript code to your site:

jQuery(function ($) {

    $('a[data-wpel-link="external"]').click(function (e) {
        if (!confirm('Are you sure you want to open this link?')) {
            // cancelled
            e.preventDefault();
            e.stopImmediatePropagation();
        }
    });

});

I am a plugin developer and my plugin conflicts with WPEL. How can I solve the problem?

If your plugin contains links it might be filtered by the WPEL plugin as well, causing a conflict. Here are some suggestions on solving the problem:

  1. Add data-wpel-link="ignore" to links that need to be ignored by WPEL plugin
  2. Use wpel_before_apply_link-action to ignore your links (f.e. containing certain class or data-attribute)
  3. Use wpel_apply_settings-filter to ignore complete post, pages, categories etc

Do you have a question? Please ask me

Requires: 4.2.0 or higher
Compatible up to: 4.5.3
Last Updated: 3 months ago
Active Installs: 20,000+

Ratings

4.3 out of 5 stars

Support

0 of 8 support threads in the last two months have been marked resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1 100,1,1 100,1,1 100,2,2 100,1,1 50,2,1
100,1,1 0,1,0 100,3,3
0,1,0 100,2,2 38,8,3
50,2,1
50,2,1 60,5,3
0,3,0 100,3,3 50,2,1
100,2,2
100,2,2
100,3,3
67,3,2 100,1,1
33,3,1 100,1,1 100,1,1 100,4,4
100,2,2
100,1,1
100,2,2
100,1,1 100,2,2
100,3,3
0,1,0 100,1,1
100,1,1
100,1,1
100,1,1 100,1,1 100,1,1 100,3,3
100,1,1
100,1,1 100,3,3
100,1,1 100,2,2
100,3,3 0,1,0 100,1,1
60,5,3 100,2,2 100,1,1
0,1,0
100,2,2
100,3,3
100,2,2
100,1,1 100,1,1
100,1,1 100,2,2 100,1,1 100,1,1 100,1,1 33,3,1 67,3,2 100,2,2