admin管理员组文章数量:1130349
I have a custom post types called Destinatiosn. These post on click opens as pages and they are organised hierarchically. Example:
Malaga
- Food
- Gallery
- Rooms
Marbella
- Food
- Gallery
- Rooms
Now in Rooms page, I am selecting to use other custom post types called "Room". In this page I will show selected custom post types. But my problem is that when I click on these custom post types URL is changing. I just want to add on existing url only the name of the room.
Example, I am in this page:
/marbella/rooms
On room custom post type click, I want room to be:
/marbella/rooms/room-name
But when I click Url changed to:
/room/room-name
function add_page_rewrite_rules(){
$url_path = trim(parse_url(add_query_arg(array()), PHP_URL_PATH), '/');
$wp_rewrite->add_permastruct( 'room', $url_path . '/%room%', false );
}
But if I change url to something else working, when I am using example /malaga or /marbella it is not working and I don't know why ?
How can I resolve my problem ?
My question here is a unique because I have added a sample of code and I do not know why url:
$wp_rewrite->add_permastruct( 'room', $url_path . '/%room%', false );
is not working but when I change to some url which does not exist works.
I have a custom post types called Destinatiosn. These post on click opens as pages and they are organised hierarchically. Example:
Malaga
- Food
- Gallery
- Rooms
Marbella
- Food
- Gallery
- Rooms
Now in Rooms page, I am selecting to use other custom post types called "Room". In this page I will show selected custom post types. But my problem is that when I click on these custom post types URL is changing. I just want to add on existing url only the name of the room.
Example, I am in this page:
/marbella/rooms
On room custom post type click, I want room to be:
/marbella/rooms/room-name
But when I click Url changed to:
/room/room-name
function add_page_rewrite_rules(){
$url_path = trim(parse_url(add_query_arg(array()), PHP_URL_PATH), '/');
$wp_rewrite->add_permastruct( 'room', $url_path . '/%room%', false );
}
But if I change url to something else working, when I am using example /malaga or /marbella it is not working and I don't know why ?
How can I resolve my problem ?
My question here is a unique because I have added a sample of code and I do not know why url:
$wp_rewrite->add_permastruct( 'room', $url_path . '/%room%', false );
is not working but when I change to some url which does not exist works.
本文标签: url rewritingRewrite url for custom post type with specific url
版权声明:本文标题:url rewriting - Rewrite url for custom post type with specific url 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749141033a2322202.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论