私のカスタム投稿との一貫性のあるURLに問題があります。 私は特定のカテゴリ内のすべての投稿を表示するページを持っている:私はへのポストのためのURLをしたいカスタム投稿を含むWordPressの一貫したURL
http://thedomain.com.au/tours/reefsleep-under-the-stars/
:私はそのカテゴリのポストをクリックすると
http://thedomain.com.au/tour_category/gbr/
私は、URLを取得しますbe:
http://thedomain.com.au/tour_category/gbr/reefsleep-under-the-stars/
これを実現する方法はわかりません。あなたは
'rewrite' => array('slug' => 'tours'),
'rewrite' => array('slug' => 'tour_category/gbr'),
スラグにあなたのコードのこの部分を変更したいかのように
// Our custom post type function
function create_posttype() {
register_post_type('tours',
// CPT Options
array(
'labels' => array(
'name' => __('Tours'),
'singular_name' => __('Tour')
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'tours'),
'hierarchical' => true
)
);
}
// Hooking up our function to theme setup
add_action('init', 'create_posttype');
function my_taxonomies_tours() {
$labels = array(
'name' => _x('Tour Categories', 'taxonomy general name'),
'singular_name' => _x('Tour Category', 'taxonomy singular name'),
'search_items' => __('Search Tour Categories'),
'all_items' => __('All Tour Categories'),
'parent_item' => __('Parent Tour Category'),
'parent_item_colon' => __('Parent Tour Category:'),
'edit_item' => __('Edit Tour Category'),
'update_item' => __('Update Tour Category'),
'add_new_item' => __('Add New Tour Category'),
'new_item_name' => __('New Tour Category'),
'menu_name' => __('Tour Categories'),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
);
register_taxonomy('tour_category', 'tours', $args);
}
add_action('init', 'my_taxonomies_tours', 0);
あなたが投稿したコードを読んで、それをあなたのdであるURLと比較しましたか?エスケープ? – David
私は持っていますが、残念なことにそれを理解するには十分理解していません。 –