// 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