2012-09-22 07:20

在wordpress中保存页面后,div id消失了


I am encountering a strange problem in wordpress as the 'id' attribute gets disappeared from the '' after saving page in wordpress.

This means if I try to save '' in a page then after save it shows ''.

I don't get a clue to fix this issue.

So please help me in sorting out this problem as soon as possible.

Thanks in advance.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • donglu8779 donglu8779 9年前

    The problem and solution are described in detail here: http://wordpress.org/support/topic/wp_update_post-strips-css-id-attribute?replies=7

    In short, this is due to WordPress' KSES module, which according to WordPress,

    ...makes sure that only the allowed HTML element names, attribute names and attribute values plus only sane HTML entities will occur in $string.

    According to the post, one of the contributors solved this problem by "inserting the following code just before the call to wp_update_post."

    global $allowedposttags;
    $allowedposttags['div'] = array('align' => array (), 'class' => array (), 'id' => array (), 'dir' => array (), 'lang' => array(), 'style' => array (), 'xml:lang' => array() );
    $allowedposttags['iframe'] = array('src' => array () );

    For a global solution, make sure to include:

    define('CUSTOM_TAGS', true);
    点赞 评论 复制链接分享