保存代码时wp_editer自动回显\?

时间:2014-09-11 06:50:47

标签: wordpress wp-editor

我在函数中添加代码在类别中创建更多字段:

add_action ( 'edit_category_form_fields', 'extra_category_fields');
//add extra fields to category edit form callback function
function extra_category_fields( $tag ) {    //check for existing featured ID
    $t_id = $tag->term_id;
    $cat_meta = get_option( "category_$t_id");
?>
<label for="extra3"><?php _e('Add Noi dung 3'); ?></label>
<?php $settings = array( 'textarea_name' => 'css[extra3]' ); wp_editor( $cat_meta['extra3'], 'css-extra3',$settings ); ?>
<?php
add_action ( 'edited_category', 'save_extra_category_fileds');
   // save extra category extra fields callback function
function save_extra_category_fileds( $term_id ) {
    if ( isset( $_POST['css'] ) ) {
        $t_id = $term_id;
        $cat_meta = get_option( "category_$t_id");
        $cat_keys = array_keys($_POST['css']);
            foreach ($cat_keys as $key){
            if (isset($_POST['css'][$key])){
                $cat_meta[$key] = $_POST['css'][$key];
            }
        }
        //save the option array
        update_option( "category_$t_id", $cat_meta );
    }
}
}

并在索引print wp_editor中添加代码: $cat_id = Category_ID; $cat_data = get_option("category_$cat_id"); echo do_shortcode($cat_data['extra3']);

当我使用wp_editor将文本添加到textarea时就可以了;但我在页面视图回显代码中添加媒体或短代码为:<a href=\"url\"width=\"300\"height=\"225\" ....

任何代码="value",当我保存=&gt; =\"value\"。如果我已保存5,则代码=\\\\\"value\\\\\"

这是我添加媒体时的图片代码 enter image description here

当我保存wp_editer时: enter image description here

如何修复它。

由于

1 个答案:

答案 0 :(得分:0)

 <?php $settings = array( 'textarea_name' => 'css[extra3]' ); wp_editor( $cat_meta['extra3'], 'css-extra3',$settings ); ?>
                                                                                                                  remove ^ php close tag

这不会执行下一个语句,因为这个?&gt;将关闭php标签