我如何在自定义wordpress页面中添加自定义标签选项?

问题描述 投票:0回答:1

看到这里没有标签框,如何在右侧面板中添加标签框,请帮助我。

enter image description here

wordpress tags
1个回答
0
投票

标记只是一种分类法类型,因此您可以为页面帖子类型创建新的分类法:

add_action( 'init', 'create_tags_for_pages_taxonomy', 0 );


function create_tags_for_pages_taxonomy() {

  $labels = array(
    'name' => _x( 'Tags', 'taxonomy general name' ),
    'singular_name' => _x( 'Tag', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Tags' ),
    'all_items' => __( 'All Tags' ),
    'parent_item' => __( 'Parent Tag' ),
    'parent_item_colon' => __( 'Parent Tag:' ),
    'edit_item' => __( 'Edit Tag' ), 
    'update_item' => __( 'Update Tag' ),
    'add_new_item' => __( 'Add New Tag' ),
    'new_item_name' => __( 'New Tag Name' ),
    'menu_name' => __( 'Tags' ),
  );    

// Now register the taxonomy

  register_taxonomy('page_tags',array('page'), array(
    'hierarchical' => false,
    'labels' => $labels,
    'show_ui' => true,
    'show_admin_column' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'topic' ),
  ));

}
© www.soinside.com 2019 - 2024. All rights reserved.