url rewriting - How can I create custom URL routes? - WordPress Development Stack Exchange

PHOTO EMBED

Thu Mar 16 2023 22:32:52 GMT+0000 (Coordinated Universal Time)

Saved by @dtholen

add_action( 'init', 'wpse26388_rewrites_init' );
function wpse26388_rewrites_init(){
    add_rewrite_rule(
        'properties/([0-9]+)/?$',
        'index.php?pagename=properties&property_id=$matches[1]',
        'top' );
}

add_filter( 'query_vars', 'wpse26388_query_vars' );
function wpse26388_query_vars( $query_vars ){
    $query_vars[] = 'property_id';
    return $query_vars;
}
content_copyCOPY

https://wordpress.stackexchange.com/questions/26388/how-can-i-create-custom-url-routes