If I want to show posts in travel category the URL is
example.com/category/travel
If I want to show posts in 2007 the URL is
example.com/2007
If I want to show posts in travel category published in 2007 the URL is
example.com/2007/?category_name=travel
My questions are
1- Why URL
example.com/category/travel/?year=2007
falls back to
example.com/2007
and related question
2- Why such an URL (to show all posts in travel category published before 2007) does not work?
example.com/category/travel/?year<=2007
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 first, the above will turn into this:
example.com/index.php?year=2007
Which will query the posts that are published in 2007.
Why year<=2007
doesn’t work?
You can’t pass comparison arguments in that way. The query argument must be equal to something, so queries like year<2000
are not valid. You can pass it like year=<2007
, but it is up to the script to honor your request. Some scripts might be programmed to recognize it, some not.
Right now, by sending year<=2007
, you are telling the server that the value for year<
is equal to 2007
.