admin管理员组

文章数量:1395780

I've noticed that the admin editor by default embeds any italic texts with <i> which I intend to use for icon styling. I much more prefer to wrap them with an <em>. How would I got about changing this?

I've noticed that the admin editor by default embeds any italic texts with <i> which I intend to use for icon styling. I much more prefer to wrap them with an <em>. How would I got about changing this?

Share Improve this question asked Aug 23, 2013 at 4:00 Staffan EstbergStaffan Estberg 3833 gold badges13 silver badges29 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3

Are you sure editor use <i> for italics? I'm almost sure it uses <em>.

However, if you want to be absolutely sure there are no <i> in your post content, let editor do what it want and then replace <i> with <em> before creating/updating posts, hooking wp_insert_post_data filter, just like:

add_filter('wp_insert_post_data','replace_em', 20, 1);

function replace_em( $post_data ) {
  if ( $post_data['post_content'] != '' ) {
    $post_data['post_content'] = str_ireplace( array('<i>', '</i>'), array('<em>', '</em>'), $post_data['post_content'] );
  }
  return $post_data;
}

Even if you insert <i> manually, they are replaced with <em> on saving.

本文标签: Change default italic from ltigt to ltemgt in admin editor