admin管理员组

文章数量:1122846

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.

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.

Share Improve this question edited Apr 13, 2017 at 12:37 CommunityBot 1 asked Jul 29, 2015 at 21:47 YuriYuri 1,1314 gold badges25 silver badges46 bronze badges 7
  • The title attribute is fine if used correctly. Why do you think that removing it is "good"? – s_ha_dum Commented Jul 29, 2015 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 Commented Jul 29, 2015 at 22:09
  • @s_ha_dum I updated the question. – Yuri Commented Jul 29, 2015 at 22:12
  • @s_ha_dum I know about that solution and it doesn't work for me, I don't know why. – Yuri Commented Jul 29, 2015 at 22:23
  • @s_ha_dum ... and that answers are not accepted yet. – Yuri Commented Jul 29, 2015 at 22:27
 |  Show 2 more comments

1 Answer 1

Reset to default 0

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?

本文标签: customizationRemove all link title attributes