1
我使用的插件下面創建一個自定義後類型:如何爲Wordpress自定義帖子類型設置自定義分類標準網址?
function post_type_listing() {
$labels = array(
'name' => _x('Listing', 'post type general name', 'themesdojo'),
'singular_name' => _x('Listing', 'post type singular name', 'themesdojo'),
'add_new' => _x('Add New Listing', 'book', 'themesdojo'),
'add_new_item' => __('Add New Listing', 'themesdojo'),
'edit_item' => __('Edit Listing', 'themesdojo'),
'new_item' => __('New Listing', 'themesdojo'),
'view_item' => __('View Listing', 'themesdojo'),
'search_items' => __('Search Listing', 'themesdojo'),
'not_found' => __('No Listing found', 'themesdojo'),
'not_found_in_trash' => __('No Listing found in Trash', 'themesdojo'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
//'rewrite' => true,
'rewrite' => array(
'slug' => 'view',
'with_front' => true
),
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title','editor','thumbnail','author', 'comments', 'amenities'),
'menu_icon' => 'dashicons-menu'
);
register_post_type('item', $args);
}
add_action('init', 'post_type_listing');
注意,在分類學的自定義改寫:
'rewrite' => array(
'slug' => 'view',
'with_front' => true
),
出於某種原因,這些文章類型仍顯示的網址http://example.com/item/%post_name%/。
我不知所措。我保存了固定鏈接並清除了緩存。沒有骰子。