Archive of a certain category in WordPress
I would like to show archives from certain category only in my 开发者_Python百科sidebar.
Something like.. Dropdown menu that has months/yeaars: May 2011 April 2011 March 2011 Etc..
And beneath of it, would be list of posts of that seleceted month: Title1 Title2 Title3
And if user would change the mont/year from the dropdown the posts beneath would change too.
I have some vague idea how this could be achieved and the way I am thinking would need lot of code/sql... any simple ways to do it? Has anyone done something like this before?
There are a couple of ways you could do this:
- Load all month/year combinations from the dropdown on page load, and use jQuery/JavaScript to switch between the post titles for the selected year. (show/hide divs containing the archived posts)
- Use Ajax to dynamically load the posts and make the dropdown field act as a get/post request. The get/post request can then be used inside query_posts to bring back the correct results.
Either way, to get the correct archives, I'd use query_posts to filter by year.
精彩评论