Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is it possible to create the following:

  • A new page dynamically daily, containing the last three posts
  • Archive this page, so that tomorrow's page is a new page, with the three newest posts

Basically I'd like to use WordPress for our news releases, we publish three each day. The day's page should contain all three stories, and then be archived so the next day's page can be created.

If you have any ideas how to setup something like this I'd appreciate it.

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

You can create date.php (you can copy the content for this from archive.php or index.php) in your theme folder which will handle all the "day" pages...

<?php get_header(); ?>

        <div id="container">
            <div id="content" role="main">

    $day = get_query_var('day');
    $monthnum = get_query_var('monthnum');
    $year = get_query_var('year');

if ( is_day() ) : ?>
    <a href="<?php echo get_day_link($year, $monthnum, $day-1); ?>">Previous day's posts</a> |
    <a href="<?php echo get_day_link(); ?>">This day's posts</a> 
    <?php if ( mktime(0, 0, 0, $monthnum, $day, $year) < mktime(0, 0, 0) ) : ?>
     | <a href="<?php echo get_day_link($year, $monthnum, $day+1); ?>">Next day's posts</a>
    <?php endif; ?> 
<?php elseif ( is_month() ) : ?>
    <a href="<?php echo get_month_link($year, $monthnum-1); ?>">Previous month's posts</a> |
    <a href="<?php echo get_month_link(); ?>">This month's posts</a> 
    <?php if ( mktime(0, 0, 0, $monthnum) < mktime(0, 0, 0) ) : ?>
     | <a href="<?php echo get_month_link($year, $monthnum+1); ?>">Next month's posts</a>
    <?php endif; ?>
<?php elseif ( is_year() ) : ?>
    <a href="<?php echo get_year_link($year-1); ?>">Previous year's posts</a> |
    <a href="<?php echo get_year_link(); ?>">This year's posts</a> 
    <?php if ( mktime(0, 0, 0, 0, 0, $year) < mktime(0, 0, 0, 0, 0) ) : ?>
     | <a href="<?php echo get_year_link($year+1); ?>">Next year's posts</a>
    <?php endif; ?>
<?php endif; ?>
    /* Queue the first post, that way we know
     * what date we're dealing with (if that is the case).
     * We reset this later so we can run the loop
     * properly with a call to rewind_posts().
    if ( have_posts() ) :

            <h1 class="page-title">
<?php if ( is_day() ) : ?>
                <?php printf( __( 'Daily Archives: <span>%s</span>' ), get_the_date() ); ?>
<?php elseif ( is_month() ) : ?>
                <?php printf( __( 'Monthly Archives: <span>%s</span>' ), get_the_date( 'F Y' ) ); ?>
<?php elseif ( is_year() ) : ?>
                <?php printf( __( 'Yearly Archives: <span>%s</span>' ), get_the_date( 'Y' ) ); ?>
<?php else : ?>
                <?php _e( 'Blog Archives', 'twentyten' ); ?>
<?php endif; ?>
<?php endif; ?>
    /* Since we called the_post() above, we need to
     * rewind the loop back to the beginning that way
     * we can run the loop properly, in full.

    /* Run the loop for the archives page to output the posts.
     * If you want to overload this in a child theme then include a file
     * called loop-archive.php and that will be used instead.

if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

                <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                    <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>

                    <div class="entry-summary">
                        <?php the_excerpt(); ?>
                    </div><!-- .entry-summary -->

                    <div class="entry-utility">
                        <?php if ( count( get_the_category() ) ) : ?>
                            <span class="cat-links">
                                <?php printf( __( '<span class="%1$s">Posted in</span> %2$s' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?>
                            <span class="meta-sep">|</span>
                        <?php endif; ?>
                            $tags_list = get_the_tag_list( '', ', ' );
                            if ( $tags_list ):
                            <span class="tag-links">
                                <?php printf( __( '<span class="%1$s">Tagged</span> %2$s' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
                            <span class="meta-sep">|</span>
                        <?php endif; ?>
                        <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment' ), __( '% Comments' ) ); ?></span>
                        <?php edit_post_link( __( 'Edit' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
                    </div><!-- .entry-utility -->
                </div><!-- #post-## -->

<?php endwhile; ?>
<?php else : ?>
    <h1 class="page-title">There are no posts for this date.</h1>
<?php endif; ?>

            </div><!-- #content -->
        </div><!-- #container -->

<?php get_sidebar(); ?>

This example can also handle the "month" and the "year" pages.

share|improve this answer
thanks for your answer. I didn't know archive.php accomplished this - thank you. Looking at my version of that file, it seems to lack some of the commands of your version above. Do you know what the differences are? Thanks again. –  Ryan Apr 25 '11 at 17:34
@Ryan I am not able to tell without investigating your archive.php. This is only one possible modification for your "date" template. –  JohnnyPea Apr 25 '11 at 22:12
add comment

WordPress will generate daily archives automatically. You can use wp_get_archives( ); and pass array('type' => 'daily') to get an archive menu broken down by day.

If your theme doesn't have an archive.php template, you can create one and the above pages will use that template. the is_day() conditional will return true on daily archive pages, so you can style those separately.

share|improve this answer
add comment

I might be missing something here, but wouldn't you just go to Settings->Reading->Posts Per Page and set it to 3 or 1? (Depends whether each press release is its own individual post or if they are all in 1 post).

If you're publishing other posts that are not press releases (ie: maybe you also have blog posts in their own category), you could also create a category for just press releases and then create a custom page template and replace the loop with something like this, depending on the theme:

query_posts( array( 'cat' => 33, 'posts_per_page' => 3, 'paged' => 
get_query_var('paged') ) );

In this example, "33" would be the category your press releases are in - you'll have to replace that with your actual category number. Then you just create a page in the post editor window, select your custom page template, and publish.

You may also want to either remove or tweak the navigation links in the theme template files also if you're worried about "older posts" or "newer posts" in the bottom.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.