Wordpress自定义Post类型自定义分类法和查询
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Wordpress自定义Post类型自定义分类法和查询相关的知识,希望对你有一定的参考价值。
Wordpress Custom Post Type, custom taxonomy and queries
//Register the custom post type register_post_type( 'my_custom_type', 'name' => _x('Custom Type Items', 'post type general name'), 'singular_name' => _x('Custom Type', 'post type singular name'), 'add_new' => _x('Add New', 'custom_type'), 'add_new_item' => __('Add New Item'), 'edit_item' => __('Edit Item'), 'new_item' => __('New Item'), 'all_items' => __('All Items'), 'view_item' => __('View item'), 'search_items' => __('Search item'), 'not_found' => __('No items found'), 'not_found_in_trash' => __('No items found in trash'), 'parent_item_colon' => '', 'menu_name' => 'Custom Type', ), 'public' => true, ) ); //Register categories for the custom type 'hierarchical' => true, 'label' => __( 'Categories for Custom Type' ), 'show_ui' => true ) ); $cat = get_terms('my_custom_type_categories'); //All categories for post type $q = new WP_Query (array ('taxonomy'=>'my_custom_type_categories','term'=> $cat->slug)); //Posts from the taxonomy
以上是关于Wordpress自定义Post类型自定义分类法和查询的主要内容,如果未能解决你的问题,请参考以下文章