admin管理员组文章数量:1317915
// route
add_action( 'init', array($this, 'wpse26388_rewrites_init') );
add_filter( 'query_vars', array($this, 'wpse26388_query_vars') );
function wpse26388_rewrites_init(){
add_rewrite_rule(
'properties/([0-9]+)/?$',
'index.php?pagename=properties&property_id=$matches[1]',
'top' );
}
function wpse26388_query_vars( $query_vars ){
$query_vars[] = 'property_id';
return $query_vars;
}
// route
add_action( 'init', array($this, 'wpse26388_rewrites_init') );
add_filter( 'query_vars', array($this, 'wpse26388_query_vars') );
function wpse26388_rewrites_init(){
add_rewrite_rule(
'properties/([0-9]+)/?$',
'index.php?pagename=properties&property_id=$matches[1]',
'top' );
}
function wpse26388_query_vars( $query_vars ){
$query_vars[] = 'property_id';
return $query_vars;
}
Share
Improve this question
edited Oct 31, 2020 at 15:19
ah jony
asked Oct 30, 2020 at 17:38
ah jonyah jony
11 silver badge2 bronze badges
2
- Please read How to Ask, then edit your question, and explain your problem better. Thanks! – fuxia ♦ Commented Oct 30, 2020 at 17:44
- sorry, now I can understand this problem. – ah jony Commented Oct 31, 2020 at 15:21
1 Answer
Reset to default 0get property_id to URL: 'index.php?properties/123' (index.php?pagename=properties&property_id=$matches[1])
$property_id = get_query_var( 'property_id', 1 ); output : 123
本文标签: How to get custom URL routes propertyid in wp php plugin
版权声明:本文标题:How to get custom URL routes property_id in wp php plugin? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742024039a2415207.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论