For left hand side, you can play around with wp_get_archives() function where you can pass parameters for Monthly, Yearly archives. Source
All categories used on the site : You can use wp_list_categories(). Source
For Right side, you can query to fetch posts for current year using WP_Query.
$current_year = the_date( 'Y' );
$args = array(
'post_type' => 'post', // or any custom post type
'date_query' => array(
array(
'year' => $current_year,
),
),
);
$query = new WP_Query( $args );
while ( have_posts() ) : the_post();
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
the_title();
endwhile;
You can take care for the structure as per your need.
Dang, thanks for your response! I didn’t even get notified of it for some reason. So that query will grab all the post thumbs from each post during that year? I assume then that it’ll keep adding years on top of the older year?
I’m also trying to add that bit of code to my page-archives.php page and it’s only listing one post_thumb. That page-archives.php is a place where you can just click and view all the categories, posts and now thumbs. I figured it’d be better to have a page like this than to depend on someone clicking a category for more information.
My photography website
-
This reply was modified 8 years, 4 months ago by
harshclimate.
-
This reply was modified 8 years, 4 months ago by
harshclimate.
Tell me what you think. After I looked over your query, I decided to redo what I was working on and came up with this:
https://gist.github.com/harshclimate/bcf99d6098e17028851e9f994d41bb67
The code that is written for displaying thumbnails will show all featured images that are in post, this means if posts were posted in 2017, that images will also be displayed as there is no year parameter passed.
If we need to show featured images for current year only, we need to change existing query (with what provided above) and have to pass year parameter.