Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 307925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:36:12+00:00 2026-05-12T07:36:12+00:00

I want to create an archive page template for WordPress that will look like

  • 0

I want to create an archive page template for WordPress that will look like this:

August 2009

  • Post 4
  • Post 3
  • Post 2
  • Post 1

July 2009

  • Post 2
  • Post 1

So, basically, I want all the posts from the blog, ordered descending by date and grouped by month.
Can someone provide me the PHP code for this?

Thanks!

PS: WordPress version is 2.8.2

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T07:36:12+00:00Added an answer on May 12, 2026 at 7:36 am

    This is a function I created a while back. It basically does what you want to do, but it’s not a template. Maybe you can adapt it.

    <?php
    /**
     * Displays a condensed list of the posts grouped by month/year. 
     *
     * @param $order The order of the posts.  Either 'DESC' or 'ASC', case sensitive.
     * @param $date_prefix Whether to prefix the posts with the month/date.
     * @param $display Whether to display the results or return it as a String. 
     */
    
    function condensed_post_list($order='DESC', $date_prefix=true, $display=true){
        global $wpdb;
    
        if( !in_array($order, array('DESC','ASC' ) ) ) $order = 'DESC';
        $query = "SELECT ID, post_title, post_date FROM $wpdb->posts ".
                 "WHERE post_type='post' AND post_status = 'publish' ".
                 "ORDER BY post_date $order";
        $results = $wpdb->get_results( $query );
    
        ob_start();
        $current_month = '';
        foreach( $results as $result ) {
            if( $current_month != mysql2date('F Y', $result->post_date)) {
                if( $current_month ) echo '</ul>';
    
                $current_month = mysql2date('F Y', $result->post_date );
                echo '<h2>'.$current_month.'</h2>';
                echo '<ul>';
            }
            echo '<li>';
            echo ($date_prefix ? mysql2date('M j: ', $result->post_date) : '');
            echo '<a href="'.get_permalink($result->ID).'">';
            echo $result->post_title.'</a></li>';
        }
        if( $current_month ) echo '</ul>';
    
        if( $display ) {
            ob_end_flush();
        } else {
            return ob_get_clean();
        }
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want create wordpress website into which I want create user management... That means
I have an archive page template that I've built that has a successful navigation
I'm trying to create a website that allows for easy theme adding/manipulation like wordpress
I have a similar problem with this ( https://wordpress.stackexchange.com/questions/9593/custom-post-type-archive-with-pagination ) and can't really figure
i want create multiple search where statement $where_search is a multiple condition from post
i want create a custom json data from the mssql 2008 results so that
i want create Dynamic Slideshow in Jquery i'm Write this code var ctx =
I want to create a new field (or two) in my table that is
I want to create a preview function for posts that allows people to view
I am creating a archive of posts which I want to create archive links

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.