Remove all link title attributes

After reading this and this, I want to remove the title attribute from all links of my blog, as that is good from accessibility point of view. How this can be achieved?

UPDATE

I found a solution how to remove title attribute from images, but it doesn't work for me.

Topic accessibility links customization Wordpress

Category Web


Do you want to preserve the images title attribute? If not here is a code that fixes that for you:

add_filter('the_content', 'remove_title_attr');

function remove_title_attr($text) {

    // Get all title="..." tags from the html.
    $result = array();
    preg_match_all('|title="[^"]*"|U', $text, $result);

    // Replace all occurances with an empty string.
    foreach($result[0] as $html_tag) {
        $text = str_replace($html_tag, '', $text);
    }

    return $text;
}

Found it here. It works on c9.io. I believe it will work in your case, too.

Edit 1: This will remove the title attribute from all your posts' content. Do you want to remove it globally from all elements?

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.