繁体   English   中英

如何在分类类别页面上包括节选选项?

[英]How to include excerpt option on taxonomy category page?

我正在尝试向我的类别页面添加摘录选项,以显示而不是描述。

因此,基本上,我需要在此屏幕上将一个框用作预览文本。

用于创建此分类法的代码是:

add_action( 'init', 'create_product_cat_external' );

function create_product_cat_external() {
  register_taxonomy(
    'ExternalProducts',
    'products',
    array(
        'label' => __( 'External Products' ),
        'rewrite' => array( 'slug' => 'externalproducts' ),
        'hierarchical' => true,
    )
  );
}

框必须在这里:

用户界面的屏幕截图

您可以使用CMB2插件并将其放入您的functions.php中 ,例如:

    add_action( 'cmb2_admin_init', 'yourprefix_register_taxonomy_metabox' );
    function yourprefix_register_taxonomy_metabox() {
        $prefix = 'yourprefix_term_';       

        $cmb_term = new_cmb2_box( array(
            'id'               => $prefix . 'edit',
            'object_types'     => array( 'term' ), // Tells CMB2 to use term_meta vs post_meta
            'taxonomies'       => array( 'products'), // Tells CMB2 which taxonomies should have these fields
            // 'new_term_section' => true, // Will display in the "Add New Category" section
        ) );

        $cmb_term->add_field( array(
            'name'       => __('Excerpt', 'default'),           
            'id'       => $prefix . 'excerpt',
            'type'     => 'wysiwyg',
            'on_front' => false,
        ) );
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM