代码之家  ›  专栏  ›  技术社区  ›  Shakil Hossain

我想添加WordPress编辑器我该怎么做?

  •  0
  • Shakil Hossain  · 技术社区  · 6 年前

    我就是这样添加自定义分类法的

    $args = array(
        'labels'                     => $labels,
        'hierarchical'               => true,
        'public'                     => true,
        'show_ui'                    => true,
        'show_admin_column'          => true,
        'show_in_nav_menus'          => true,
        'show_tagcloud'              => true,
        'supports' => array( 'editor', 'thumbnail')
    );
    register_taxonomy( 'bookwriters', 'product', $args );
    

    enter image description here

    0 回复  |  直到 6 年前
        1
  •  0
  •   Obmerk Kronen    6 年前

    你可以试试这样的方法:

    /**
     * TinyMCE editor in taxonomy page
     */
    function o99__category_editor() {
        global $pagenow, $current_screen;
    
        if( $pagenow == 'edit-tags.php' ) {
            require_once(ABSPATH . 'wp-admin/includes/post.php'); // we need these
            require_once(ABSPATH . 'wp-admin/includes/template.php');
    
            wp_tiny_mce( false, array( 'editor_selector' => 'description', 'elements' => 'description', 'mode' => 'exact' )); // first argument TRUE will give the light version
        } 
    }
    add_action( 'init', 'o99__category_editor' );
    

    另外,由于TinyMCE编辑器作为默认编辑器被删除,您可能需要获取经典编辑器插件。也没有测试。