简体   繁体   English

WordPress自定义页面URL重写

[英]WordPress Custom Page URL rewrite

i have custom page on wordpress which is accessible in following way: 我在wordpress上有自定义页面,可通过以下方式访问:

domain.com/custom-page/1

how could i achieve following url pattern: 我如何实现以下网址格式:

domain.com/custom-page/1/Title-of-Page-Content

or 要么

domain.com/custom-page/1-Title-of-Page-Content

it seems like after "custom-page" other then integer value is not acceptable. 似乎在“自定义页面”之后,则不能接受整数值。

Note: i have tried .htaccess way and by adding following code in theme/functions.php 注意:我已经尝试过.htaccess方式,并在theme / functions.php中添加以下代码

function custom_rewrite_rule() {
    add_rewrite_rule('custom-page/([^/]*)/([^/]*)?$','index.php?pagename=custom-page&_id=$matches[1]&title=$matches[2]','top');
}
add_action('init', 'custom_rewrite_rule', 10, 0);

any help? 任何帮助? Thanks in advance. 提前致谢。

When you are in the Admin area of Wordpress, go to the Settings pop out menu. 当您位于Wordpress的“管理”区域时,请转到“设置”弹出菜单。 There is an option for Permalinks. 固定链接有一个选项。 Go there and select the pattern you'd like for your page slugs. 转到此处,然后为您的页面提示选择所需的模式。 I think the specific one you want to select is Post Name, according to what you are saying. 我认为您要选择的具体名称是邮政名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM