Last active
June 22, 2017 10:21
-
-
Save qwersk/6680cb0f61fe3ea2e68da2c78e776be5 to your computer and use it in GitHub Desktop.
ADD CUSTOM TAXONOMY #WP #WORDPRESS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//hook into the init action and call create_book_taxonomies when it fires | |
add_action( 'init', 'create_topics_hierarchical_taxonomy', 0 ); | |
//create a custom taxonomy name it topics for your posts | |
function create_topics_hierarchical_taxonomy() { | |
// Add new taxonomy, make it hierarchical like categories | |
//first do the translations part for GUI | |
$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' => __( 'Категории' ), | |
); | |
// Now register the taxonomy | |
register_taxonomy('reviews_category',array('reviews'), 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