![](/img/trans.png)
[英]Wordpress + Wpml translated slug of custom post type with custom url rewrite
[英]Wordpress add rewrite URL look like WPML
與標題相同,我要訪問鏈接:
mysite.domain/hello-word
mysite.domain/my_slug/hello-word
是相同的鏈接,看起來像WPML:
mysite.domain/hello-word
mysite.domain/en/hello-word
我嘗試:
function custom_rewrite_tag() {
add_rewrite_rule('^([^/]*)/?/([^/]*)/?', 'index.phptheme_var=$matches[0]&pagename=$matches[1]', 'top');
add_rewrite_tag('%theme_var%', '([^&]+)');
}
add_action('init', 'custom_rewrite_tag', 10, 0);
但沒有工作,有人可以幫助我嗎?
你忘了問號嗎?
add_rewrite_rule('^([^/]*)/?/([^/]*)/?', 'index.php?theme_var=$matches[0]&pagename=$matches[1]', 'top');
在index.php和theme_var之間
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.