0

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

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 );
    }
}
}

并在索引打印 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"当我保存 => 时的任何代码=\"value\"。如果我保存 5 有代码=\\\\\"value\\\\\"

这是我添加媒体时的图片代码 在此处输入图像描述

当我保存 wp_editer 时: 在此处输入图像描述

怎么解决的。

谢谢

4

1 回答 1

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

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

于 2014-09-12T07:21:46.367 回答