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 2 weeks, 6 days ago by  harshclimate.

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

Viewing 3 replies - 1 through 3 (of 3 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(
    		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.

    harshclimate

    (@harshclimate)

    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

    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

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.