Support » Fixing WordPress » Need some help developing an archive page

  • Greetings,

    What I have is a two column layout. The left side would need:

    • All archives by title from the whole year
    • All categories used on the site (including post count)
    • Monthly archives (including post count)
    • Yearly archives (including post count)

    On the right I would only need:

    • All of the post_thumbnails with the title of the page being posts from the current year

    What I have now is very inflexible and I have a feeling it’ll break if the year changes. Can someone please look at it and tell me if it’s going to break, if there’s a better way to get what I need based on someone else’s existing archive?

    • This topic was modified 9 months, 3 weeks ago by  harshclimate.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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(
    			'year'  => $current_year,
    $query = new WP_Query( $args );
    while ( have_posts() ) : the_post();
    if ( has_post_thumbnail() ) {

    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 9 months, 1 week ago by  harshclimate.
    • This reply was modified 9 months, 1 week 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:

    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Need some help developing an archive page’ is closed to new replies.