I need to rewrite a URL form WP. I use this:
add_rewrite_rule( ‘property-for-sale([^/]+)/([^/]+)/$’, ‘archive-property-for-sale.php?areas=$matches[1]&price=$matches[2]′, ‘top’);
i want to rewrite the url from /wordpress/property-for-sale/?area=any&price=1000000/
to /wordpress/property-for-sale/any/1000000/
property-for-sale
and area
are made with Types( Custom Fields)
with taxonomy
.
If it works anything like preg_replace which it probably does then the following will help you.
preg_match_all('~/([^/]+)/([^/]+)/\??area=([^&]+)?&price=([^&]+)/~',"/wordpress/property-for-sale/?area=any&price=1000000/",$m);
print_r($m);
echo preg_replace('~/([^/]+)/([^/]+)/\??area=([^&]+)?&price=([^&]+)/~','/$1/$2/$3/$4/',"/wordpress/property-for-sale/?area=any&price=1000000/");