Skip to content

Instantly share code, notes, and snippets.

@flayder
Last active January 5, 2016 14:22
Show Gist options
  • Select an option

  • Save flayder/a1e135a37906d7ad3bfe to your computer and use it in GitHub Desktop.

Select an option

Save flayder/a1e135a37906d7ad3bfe to your computer and use it in GitHub Desktop.
//хук в init action и вызов create_book_taxonomies когда хук сработает
add_action( 'init', 'create_topics_hierarchical_taxonomy', 0 );
//задаем название для произвольной таксономии Topics для ваших записей
function create_topics_hierarchical_taxonomy() {
// Добавляем новую таксономию, делаем ее иерархической вроде рубрик
// также задаем перевод для интерфейса
$labels = array(
'name' => _x( 'Topics', 'taxonomy general name' ),
'singular_name' => _x( 'Topic', 'taxonomy singular name' ),
'search_items' => __( 'Search Topics' ),
'all_items' => __( 'All Topics' ),
'parent_item' => __( 'Parent Topic' ),
'parent_item_colon' => __( 'Parent Topic:' ),
'edit_item' => __( 'Edit Topic' ),
'update_item' => __( 'Update Topic' ),
'add_new_item' => __( 'Add New Topic' ),
'new_item_name' => __( 'New Topic Name' ),
'menu_name' => __( 'Topics' ),
);
// Теперь регистрируем таксономию
register_taxonomy('topics',array('post'), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'topic' ),
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment