$args = array(
'post_type' => 'post',
'posts_per_page' => -1,
'order' => 'DESC',
'orderby' => 'date'
);
$posts = get_posts( $args );
$years = array();
foreach ( $posts as $post ) {
$year = get_the_date( 'Y', $post->ID );
if ( ! in_array( $year, $years ) ) {
$years[] = $year;
}
}
$current_year = isset( $_GET['year'] ) ? $_GET['year'] : '';
$base_url = get_home_url() . '/';
?>
'post',
'posts_per_page' => 10,
'paged' => $paged,
'order' => 'DESC',
'orderby' => 'date',
'year' => $current_year
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
// display your post content here
}
$big = 999999999;
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $query->max_num_pages
) );
}
wp_reset_postdata();
}
?>