add_action( 'init', 'rule' );
function rule() {
add_rewrite_rule(
'^(en|fr|de|ru)/(.?.+?)/?$',
'index.php?lang=$matches[1]&pagename=$matches[2]',
'top'
);
}
The code above is part of all my code. First of all, I must say, my code works on everything else. (Date, Category, Label, etc.)
Even the code above works fine for "post_type=page
" ie page type. However, if "post_type=post
" is entered,
It automatically redirects "localhost/en/hello-world
" to "localhost/hello-world
". But it works fine if a page like "localhost/en/contact
" is entered.
- "
Localhost/en/category/food
" - "
Localhost/en/2019/08/28
" - "
Localhost/en/tag/food
"
I don't make sense of why a "post
" doesn't work when thats are working properly.
Who knows, maybe I should write separate rules for "page
" and "post
". and!
I tried:
add_rewrite_rule(
'^(en|fr|de|ru)/(.?.+?)/?$',
'index.php?lang=$matches[1]&pagename=$matches[2]&post_type=posts',
'top'
);
add_rewrite_rule(
'^(en|fr|de|ru)/(.?.+?)/?$',
'index.php?lang=$matches[1]&pagename=$matches[2]',
'top'
);
but again I didn't get a result. I don't know if I add any "custom_post_type" to the same problem.
I am looking forward to your thoughts and solutions. Thanks.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745205042a4616552.html
评论列表(0条)