The default behaviour for monthly and yearly archives is to get a set of posts for that period (limited by the max-posts-per-page setting) and show them in full, with paging. I would like a different behaviour for yearly archives (it would seem more natural in most blogs to me, BTW) : show a list of all posts for that year -like an index-, perhaps with excerpts. Which would be the recommended way?


if you only want this for yearly archives, then you could create a custom date.php template that limits the posts to displaying just the title (and possibly excerpt as you wish)


otherwise, you could also create archive.php but it that would effect all your archives. date.php would only apply to your time-based archives.

then i'd modify the query using pre_get_posts() to override the posts_per_page parameter.

pre_get_posts for modifying the query: http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts#Example:_Changing_the_number_of_posts_per_page.2C_by_post_type

you said you only want this on the year archives, so we'll use the conditional is_year()


add this to your functions.php:

add_action('pre_get_posts', 'wpa_44980' );

function wpa_44980( $wp_query ) {

    if( is_year() ) {
        set_query_var('posts_per_page', '-1');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.