Answer the question
In order to leave comments, you need to log in
Taxonomy in Wordpress?
Hello.
Created a new post type "Applications", added taxonomies to it: "Category", "Device", "Platform".
Connecting a new record type:
add_action('init', 'app_init');
function app_init() {
// описываем наш тип контента
$args = array(
'label' => __('Приложение'),
'labels' => array(
'edit_item' => __('Редактировать приложение'),
'add_new_item' => __('Нобавить новое приложение'),
'view_item' => __('Просмотр'),
),
'singular_label' => __('app'),
'public' => true,
'show_ui' => true,
'_builtin' => false,
'_edit_link' => 'post.php?post=%d',
'capability_type' => 'post',
'hierarchical' => false,
'supports' => array('title', 'editor', 'thumbnail')
);
// регистрируем новый тип
register_post_type( 'app' , $args );
register_taxonomy( 'category', 'app',
array ('hierarchical' => true, 'label' => __('Категория'),
'singular_label' => __('category'),
'query_var' => 'category')
);
register_taxonomy( 'device', 'app',
array ('hierarchical' => true, 'label' => __('Устройство'),
'singular_label' => __('device'),
'query_var' => 'device')
);
register_taxonomy('platform','app',
array ('hierarchical' => true, 'label' => __('Платформа'),
'singular_label' => __('platform'),
'query_var' => 'platform')
);
Answer the question
In order to leave comments, you need to log in
Maybe late, but still:
1. All your posts with the new post type will be displayed on the page yourdomain.com/?post_type=app
If you want a prettier url, add the following arguments when registering the post type:
$args = array(
....
'has_archive' => true,
'rewrite' => array(
'slug' => 'apps',
'with_front' => false
)
}
<?php the_terms($post->ID, 'device'); ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question