Display all posts that were published before full post on single.php

The way I would like my blog to work is a user clicks on a post that was published on 12th March 2012 (for example) they get taken to single.php where the content of that post is displayed as normal.

Beneath this content I would like to display all posts published before it, not after. How can I edit my existing loop to do this? Here’s my working loop that currently displays all posts, no matter what the date:

<!-- Show all posts within this category -->
                <div id="post-wrap">
                <?php
                $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                $args= array(
                    'category_name' => 'offsite', 
                    'paged' => $paged,
                    'posts_per_page' => 1
                );
                query_posts($args);
                if( have_posts() ) :?>

                    <?php while ( have_posts() ) : the_post(); ?>


                <article>
                    <?php the_post_thumbnail(); ?>
                    <h1><a href="<?php the_permalink()?>"><?php the_title(); ?> <span>/ <?php the_time('l jS F') ?></span></a></h1>

                    <?php the_content(''); ?>

                    <div class="a-options">
                        <a href="#new" class="comments scrollto">Comment</a>

                        <!-- share -->
                            <div class="share-button">
                                <div class="buttons">
                                    <div class="facebook">                          

                                        <div class="fb-like" data-href="www.MyKettlesYard.co.uk" data-send="false" data-layout="button_count" data-width="95" data-show-faces="false" data-font="Arial"></div>

                                        <span class="child-pseudo">Facebook</span>
                                    </div>

                                    <div class="twitter">

                                        <a href="https://twitter.com/share" class="twitter-share-button" data-url="www.MyKettlesYard.co.uk" data-text="Kettles Yard, Cambridge - www.MyKettlesYard.co.uk" data-count="horizontal">Tweet</a><script src="//platform.twitter.com/widgets.js"></script>

                                        <span class="child-pseudo">Twitter</span>
                                    </div>
                                </div>

                                <span class="pseudo-button">+ Share</span>
                             </div> <!--! /share -->

                    </div><!--! /a-options -->

                    <?php global $withcomments;
                    $withcomments = 1;
                    comments_template(); ?>

                  </article>


                <?php endwhile; ?>

                    <div id="next-prev-wrap" class="nextprev"><?php next_posts_link( 'Older posts /', $post->max_num_pages ); ?> <?php previous_posts_link( 'Newer posts', $post->max_num_pages ); ?></div>

                <?php endif; ?>
                <?php wp_reset_query(); ?>
                </div>

Related posts

Leave a Reply

1 comment

  1. How about something along these lines?

    function my_filter_where( $where = '' ) {
        global $post;
    
        $where .= ' AND post_date <= "'.$post->post_date.'"';
        return $where;
    }
    
    add_filter( 'posts_where', 'my_filter_where' );
    $query = new WP_Query( $query_string );
    remove_filter( 'posts_where', 'my_filter_where' );