wordpress - How can I display post link group by year? -
I want to display a list of post link groups over the year. The archive function does not do this example:
2010 Blender 2.53 release gamequiry 0.5 released sinkfig 0.62.02 released ... 2009 GIMP 2.67 released Blender 2.52 release
< P> How can I do this?
query all your posts sorted by date of posting (I think descending?). You print them one by one, miss the year, and when the year of the current post is not the same as the year of the previous post, you know that you have to print a year's label.
query_posts (array ('nopaging' => 1, / * we want all posts, so disable paging; order is the default according to date * /)); $ Prev_year = Null; If (is_pause ()) {while (is_posts ()) {the_post (); $ This_year = get_the_date ('Y'); If ($ prev_year! = $ This_year) {// Year limit! (! Is_null ($ prev_year)) {// A list is already open, turn it off first & lt; / Ul & gt; '; } Echo & lt; H3 & gt; '. $ This_year '& lt; / H3 & gt; '; Echo & lt; Ul & gt; '; } Echo & lt; Li & gt; '; // Print the link of your post here, left the exercise for the reader 'echo' & lt; / Li & gt; '; $ Prev_year = $ this_year; } Echo '& lt; / Ul & gt; '; }
Comments
Post a Comment