Wordpress Template PHP Help

Discussion in 'PHP' started by smartalex4, Mar 16, 2015.

  1. #1
    After an extenisive search I finally found the following code that lets me display my WP posts on a WP page. This is great, but what I really need is to be able to display just the posts created in the last 24 hours. Does anyone know what changes I need to make to limit the results to just the last 24 hours or so?

    <?php/*
    Template Name: All posts
    */
    ?>
    <?php
    $debut = 0; //The first article to be displayed
    ?>
    <?php while(have_posts()) : the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <ul>
    <?php
    $myposts = get_posts('numberposts=-1&offset=$debut');
    foreach($myposts as $post) :
    ?>
    <li><?php the_time('d/m/y') ?>: <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    </ul> <?php endwhile; ?>
    Code (markup):
    Thank you very much
     
    smartalex4, Mar 16, 2015 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    PoPSiCLe, Mar 16, 2015 IP