php - How to include excerpt option on taxonomy category page? -
i trying add excerpt option category page, display instead of description.
so basically, need box on screen able used preview text.
the code used create 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 box needs here:
you can use cmb2 plugin , put in functions.php example:
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 use term_meta vs post_meta 'taxonomies' => array( 'products'), // tells cmb2 taxonomies should have these fields // 'new_term_section' => true, // display in "add new category" section ) ); $cmb_term->add_field( array( 'name' => __('excerpt', 'default'), 'id' => $prefix . 'excerpt', 'type' => 'wysiwyg', 'on_front' => false, ) ); }
Comments
Post a Comment