S
S
Socrates2018-03-20 14:21:25
WordPress
Socrates, 2018-03-20 14:21:25

Additional field for taxonomy?

Guys, can you tell me how to make an additional field for him when registering a custom taxonomy?
There is a field "Description"
We need another field "Announcement"
Taxonomy registration code:

add_action( 'init', 'create_taxbeton' );
function create_taxbeton() {
  register_taxonomy('taxbeton', array('cpt_beton'), array(
    'label'                 => _x( 'Типы бетона', 'taxonomy general name' ), // определяется параметром $labels->name
    'labels'                => array(
      'name'              => _x( 'Типы бетона', 'taxonomy general name' ),
      'singular_name'     => _x( 'Тип бетона', 'taxonomy singular name' ),
      'search_items'      => __( 'Поиск по типам бетона' ),
      'all_items'         => __( 'Все типы бетона' ),
      'parent_item'       => __( 'Родительская' ),
      'parent_item_colon' => __( 'Родительская:' ),
      'edit_item'         => __( 'Изменить тип бетона' ),
      'update_item'       => __( 'Обновить тип бетона' ),
      'add_new_item'      => __( 'Добавить новый тип бетона' ),
      'new_item_name'     => __( 'Название' ),
      'menu_name'         =>  __( 'Типы бетона' ),
    ),
    'description'           => '', // описание таксономии
    'public'                => true,
        'publicly_queryable'    => true,
    'show_in_nav_menus'     => true, // равен аргументу public
    'show_ui'               => true, // равен аргументу public
    'show_tagcloud'         => false, // равен аргументу show_ui
    'hierarchical'          => true,
    'rewrite'               => array('slug'=>'products', 'with_front'=>true),
    'show_admin_column'     => true, // Позволить или нет авто-создание колонки таксономии в таблице ассоциированного типа записи. (с версии 3.5)
  ) );
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Vorotnev, 2018-03-20
@Karmov69

Additionally, when registering, there is no way, register_taxonomy() does not have such functionality.
But terms, just like posts, can use a metadata table (wp_termmeta) via the Metadata API. Accordingly, you can make the field yourself or use some plugin like Advanced Custom Fileds.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question