I'm trying to create a rewrite rule in Wordpress to create direct pretty links to search results.
I'm working with a custom post type called 'object'
My result page is located at this url : http://www.domain.com/objects/
I want to create this kind of URL to point a listing of new objects : http://www.domain.com/objects/new
The rewritten query must be : http://www.domain.com/objects/?filter=new
I will then be able to use the $_GET['filter'] value to query my objects (meta_query)...
my problem
I've try to to this with this code:
add_rewrite_tag('%filter%','([^&]+)');
add_rewrite_rule('objects/new/','objects/?filter=new','top');
.htaccess looks then like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^objects/new/ /objects/?filter=new [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Unfortunately, when I try to reach the URL http://www.domain.com/objects/new I've got a 404 error :(
Debug bar show me this:
Request:
objects/new
Query String:
attachment=new
Matched Rewrite Rule:
[^/]+/([^/]+)/?$
Matched Rewrite Query:
attachment=new
Can someone tell me why Wordpress try to retrieve an attachment? Is something wrong in my rewrite rule or am I missing something?
Thanks in advance for your help!
