簡體   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