I am looking to have a drop down menu at the top of a category page that will allow me to then filter the posts by date.
I will most probably have to make use of custom fields, but that isn’t the issue.
I know you can make a custom post query using GET style variables, but with pretty URLs enabled, I cannot seem to use the GET variables to filter specific posts (e.g. www.domain.com/category/?orderby=title&order=ASC
etc etc )
I have tried looking for plugins, but nothing seems to jump out at me for what I need, and I have also noticed a lot of talk on here about similar subjects, with no decent solutions for my situation.
The general query would be this like :
For dropdown, you can do something like this :
And another option :
i was looking for search posts by date. didn’t able to found suitable solution on stackoverflow. i then printed the wp_query object and sorted this thing out. it worked for me. in my scenario m searching for posts by their title or by date. here is the code for the hook.
as u can notice this filter automatically checks if passed param is string or date. m using
to get results of post only other wise it will fetch page too.
suppose u have date under each post u can add href to that date. so to get all posts of that date
on the end of href add search param like ?s=something
and so on the template u dont need to write ur custom forwhile just use default template functions like
have_posts()