Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Template Name: Front Page -3 days
- */
- ?>
- <?php
- /**
- * The template for displaying all pages.
- *
- * This is the template that displays all pages by default.
- * Please note that this is the WordPress construct of pages
- * and that other 'pages' on your WordPress site will use a
- * different template.
- *
- * @package WordPress
- * @subpackage Twenty_Ten
- * @since Twenty Ten 1.0
- */
- get_header(); ?>
- <div id="container">
- <div id="content" role="main">
- <?php
- // list all posts, sectioned by post date
- function filter_where($where = '') {
- //posts in the last 3 days
- $where .= " AND post_date > '" . date('Y-m-d', strtotime('-2 days')) . "'";
- return $where;
- }
- add_filter('posts_where', 'filter_where');
- $args=array(
- 'orderby' => 'date',
- 'order' => 'DESC',
- 'posts_per_page'=>-1,
- 'caller_get_posts'=>1
- );
- $my_query = new WP_Query($args);
- if( $my_query->have_posts() ) {
- while ($my_query->have_posts()) : $my_query->the_post();
- $this_date = get_the_time(__('l d F Y'));
- if ($this_date != $last_date) {
- $last_date = $this_date;
- echo '<h2>'.$last_date.'</h2>';
- } ?>
- <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a><br /><?php the_content(); ?></p>
- <?php
- endwhile;
- } //if ($my_query)
- wp_reset_query(); // Restore global post data stomped by the_post().
- ?>
- </div><!-- #content -->
- </div><!-- #container -->
- <?php get_sidebar(); ?>
- <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement