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?


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

  • The title attribute is fine if used correctly. Why do you think that removing it is "good"? – s_ha_dum Jul 29 '15 at 22:02
  • 1
    It can be abused and thus breaking the accessibility. That's why it was removed from the default WP TinyMCE editor. – denis.stoyanov Jul 29 '15 at 22:09
  • @s_ha_dum I updated the question. – Iurie Malai Jul 29 '15 at 22:12
  • @s_ha_dum I know about that solution and it doesn't work for me, I don't know why. – Iurie Malai Jul 29 '15 at 22:23
  • @s_ha_dum ... and that answers are not accepted yet. – Iurie Malai Jul 29 '15 at 22:27

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?

  • So your answer is a copy/paste of an answer (a much, much better one) by EAMann? Please don't do that but thanks for pointing out the duplicate. – s_ha_dum Jul 29 '15 at 22:13
  • @denis.stoyanov For now yes, I want to remove it globally from all elements, but I must investigate this more. Thank you! – Iurie Malai Jul 29 '15 at 22:16
  • @denis.stoyanov I know about this function, but it doesn't work for me. – Iurie Malai Jul 29 '15 at 22:18
  • @s_ha_dum Yes it is. And I've included a link to his reply (EAMann) where he (Iurie) can find more detailed information. Is this against the Terms? I'll re-read the forum Terms of Use. I guess that has slipped out from my mind. Sorry for that. Will know in future. Thanks! – denis.stoyanov Jul 29 '15 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.