Skip to content
WordPress Plugin that removes empty links from the DOM
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Empty Link Vanisher

WordPress Plugin that removes empty links from the DOM


Once activated, links that have an empty href attribute (a href='') will be removed from a post or page using jQuery. Users have the option to target links with a class or ID. Multiple classes should work when separated by a space (like .class1 .class2 #your-id etc).


John and I were discussing this code, which makes the parent object for empty links disappear using jQuery. This can be useful if clikckable buttons are presented in WordPress that are not properly populated. Rather than creating dummy links, the button can hence be remoevd with ease if no link is present. The code could be exapnded to make links to default URLs disappear too.

The challence was to wrap this functionality into a standalone WordPress plugin. I had done something similar before when I wrote the P2 Header Ad plugin, which required a block of text to be inserted into the DOM and positioned correctly using jQyery.

This time however, I had to exchange data between PHP and JavaScript, something I hadn't done before. Thanks to the wp_localize_script() function, it's a breeze. This plugin illustrates how to do it.

You can’t perform that action at this time.