0
我有默認的鏈接到我的文章'/ video/translate/continuous_present'(continuous_present
是一個帖子名)',我想讓它看起來更像這樣'/ exercise/continuous_present',但以前的URL也應該可用。自定義帖子類型的WordPress替代URL
我試圖創建一個重寫規則,它的工作原理,但重定向我舊的鏈接
add_action('init', function() {
add_permastruct('single-exercise', '^exercise/%postname%', array('with_front' => false));
flush_rewrite_rules();
}
我$wp_rewrite
變量包含這樣的值
WP_Rewrite Object
(
[permalink_structure] => /video/%postname%
[front] => /video/
...
下面是我註冊我的自定義文章類型:
register_post_type('translate',
array(
'labels' => array(
'name' => 'Упражнения',
'singular_name' => 'Упражнение'
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'translate'),
'hierarchical' => true,
'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'page-attributes', 'comments', 'revisions', 'post-formats'),
'menu_position' => 6,
'taxonomies' => array('translates_category', 'category'),
)
);
register_taxonomy('translates_category',array('translate'), array(
'labels' => array(
'name' => 'Рубрики упражнений',
'singular_name' => __('Category', 'engl')
),
'hierarchical' => true,
'rewrite' => array('slug' => 'translates-category'),
));
有什麼建議嗎?
PS: nginx的(無阿帕奇)