On both category and monthly archive pages I am trying to display all posts on a single page (instead of 10 per page). On category pages I already managed this with the following code:
$cat_id = get_cat_ID( single_cat_title(null, false) ); query_posts( "cat=$cat_id&posts_per_page=-1" );
I believe on monthly archives I can achieve the same thing with this:
$year = ??? $monthnum = ??? query_posts( "year=$year&monthnum=$monthnum&posts_per_page=-1" );
However, I don’t know how to get the $year and $monthnum variables, as you can see above. I searched on WordPress codex, but it only shows how to get the current year and month, while what I need is the year/month of the archive page being displayed at the moment.
- The topic ‘How to display all posts on monthly archives?’ is closed to new replies.