5

I want to output on the homepage the posts from the lastest 3 days.

Like this:

30/03/12

    post 1
    post 2
    post 3

29/03/12

    post 1
    post 2
    post 3

28/03/12

    post 1
    post 2
    post 3

I tried:

On 30/03/12 I have 5 posts

On 29/03/12 I have 4 posts

On 28/03/12 I have 3 posts

So the 3rd day is missing now 2 posts.

Also I want to use this on the archive page.

3 days a page.

On page 2 the next 3 days.

Here is my loops file

<div id="post-<?php the_ID(); ?>" class="entry-box">
<?php $embed = get_post_meta(get_the_ID(), 'tj_video_embed', TRUE); ?>
<?php if($embed && (get_option('videoplus_fancybox_enable') == 'on')){
    $embed_url = '';
    $mode = '~http://[\d\w\s:/.]*~iS';
    preg_match($mode,$embed,$embed_url);
?>
<a href="<?php echo $embed_url[0];?>" rel="bookmark" class="various fancybox.iframe">
<?php } else { ?>
    <a href="<?php the_permalink(); ?>" rel="bookmark">
<?php } ?>
    <?php if(has_post_thumbnail()){?>
        <?php the_post_thumbnail('entry-thumb', array('class' => 'entry-thumb')); ?>
    <?php } else { ?>
    <?php $img_url = get_post_meta(get_the_ID(), 'tj_video_img_url', TRUE); ?>
        <?php if($img_url != null) { ?><img src="<?php echo $img_url; ?>" alt="<?php the_title(); ?>" class="entry-thumb"/><?php } ?>
    <?php } ?>

    <?php if($embed) { ?>
        <div class="video-flag"></div>
    <?php }?>
</a>
<div class="entry-meta">
    <?php the_time('M j, Y'); ?> &middot; by <?php the_author_posts_link(); ?>
    <span class="entry-comment">
        <?php comments_popup_link( __( '0', 'theme junkie' ), __( '1', 'theme junkie' ), __( '%', 'theme junkie' ) ); ?>
    </span>
</div><!-- .entry-meta -->
<h2 class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<div class="entry-content">
    <p><?php the_excerpt(); ?></p>
</div><!-- .entry-content -->
</div><!-- #post-<?php the_ID(); ?> .entry-box -->
1
  • 3
    Where are you excluding posts based on dates?
    – fdsa
    Commented Jun 8, 2012 at 2:33

1 Answer 1

1

Not a bad idea for display of a blog home page and I would be interested in what you came up with, but thinking through the idea for implementation beyond the first page would be problematic:

Pagination - If it is just the blog home then you can easily set an offset for starting on page 2, but if each page has a variable number of posts on it (could be one, could be 20 in the past 3 days?)

Archive home - Archives cover a lot of areas including tags, categories, date archives and others. I am not sure that this display would work for anything but the home page of each of these.

1
  • +1 for pagination issues. Variable amount of posts per page (and case of zero posts in page) would be complicated to neatly implement and possibly prohibitively expensive to compute.
    – Rarst
    Commented Oct 15, 2012 at 22:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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