Custom rewrite rule

Add the following to your .htaccess, in between the <IfModule mod_rewrite.c>: RewriteCond %{QUERY_STRING} (^|&)filter=all&search_text=&type=(.*)&location=(.*)&cs_directory_search_location=Yes&search_view=&goe_location_enable=No&cs_loc_max_input=5&cs_loc_incr_step=1&submit=&action=cs_directory_map_search RewriteRule ^(.*)$ /directorio/%2/%3/? [R=301,L] You can confirm the logic through this .htaccess tester. Your default .htaccess created from WordPress should now look like the following: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f … Read more

Rewrite URL for results of a custom WP_Query

You could try using the add_rewrite_endpoint function, which would actually let you avoid any htaccess modification (unless you need $_GET). Example: function add_custom_rewrite_ep() { add_rewrite_endpoint(‘cata’, EP_PAGES); add_rewrite_endpoint(‘catb’, EP_PAGES); add_rewrite_endpoint(‘catc’, EP_PAGES); } add_action( ‘init’, ‘add_custom_rewrite_ep’ ); Make sure you flush your rewrite rules. So then, if your URL is /questions/cata/foo/catb/bar/catc/more/, you can access the values with … Read more

How to create an endpoint without creating sub endpoints?

The rewrite rule added by: add_rewrite_endpoint( ‘my-endpoint’, EP_AUTHORS ); is author/([^/]+)/my-endpoint(/(.*))?/?$ => index.php?author_name=$matches[1]&my-endpoint=$matches[3] so it assumes anything after e.g. /author/henrywright/my-endpoint/…. You can try instead to replace it with add_rewrite_rule() e.g. add_rewrite_rule( ‘^author/([^/]+)/my-endpoint/?$’, ‘index.php?author_name=$matches[1]&my-endpoint=1’, ‘top’ );

Using Blog Parent Slug on Blog Posts Only

Just set your custom permalink structure to: /theblog/%postname%/ If you have any custom post types used on your site, you’ll need to make sure that they don’t get the /theblog/ prepended to their URLs. To remove it, simply set with_front to false where the custom post types are registered: ‘rewrite’ => array(‘slug’ => ‘portfolio’, ‘with_front’ … Read more

How to perform a query at the URL?

The reason behind this is how the URL rewriting works. No matter what is the setting of your permalink structure, all the requests will be redirected to index.php. So, for example: example.com/category/travel will eventually turn into: example.com/index.php?cat=travel So in your example: example.com/category/travel/?year=2007 will be turned into: example.com/index.php?cat=travel&year=2007 and possibly because the last argument overrides the … Read more