简体   繁体   English

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

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

I am trying to add an excerpt option to my category page, to display instead of my description. 我正在尝试向我的类别页面添加摘录选项,以显示而不是描述。

So basically, I need a box on this screen which will be able to be used as preview text. 因此,基本上,我需要在此屏幕上将一个框用作预览文本。

The code used to create this taxonomy is: 用于创建此分类法的代码是:

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

and the box needs to be here: 框必须在这里:

用户界面的屏幕截图

You can use CMB2 plugin and put this in your functions.php for example: 您可以使用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.

相关问题 如何在 wordpress 上设置分类类别作为我的页面? - How can I set up a taxonomy category as my page on wordpress? 如何在wordPress中按分类法类别ID或分类法类别名称获取所有分类法类别的帖子? - How can i get all post of taxonomy category post by taxonomy category id or taxonomy category name in wordPress? 如何在WordPress的页面菜单中同时包含类别和页面? - How to include both category and page in page's menu in WordPress? 高级自定义字段在类别页面上显示不正确。 我如何只限于分类页面? - Advanced custom fields displaying incorrectly on category pages. How do i limit to my taxonomy page only? 如何在子类别存档页面上回显自定义分类类别的父名称和永久链接 - How to echo parent name and permalink of custom taxonomy category on subcategory archive page 需要为类别添加摘录 - Need to add a excerpt to a category 如何在特定分类类别内执行搜索 - How to perform a search inside a specific taxonomy category 如何在类别循环中显示自定义分类字段? - How to display custom taxonomy fields into category loop? 如何获取特定类别Wordpress的帖子的标题,图像和摘录 - How to get Title, Image and excerpt of posts of a specific category Wordpress 如何在magento的类别页面上添加多个排序选项? - How can i add multiple sorting option on category page in magento?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM