• Hi everybody,

    I’m encountering this problem with my loop, I’m finding a solution to display posts in a specific range of date. I’m using wordpress to submit upcoming events and I need two loops on my home page to display:

    1° – future posts in the next 48 hours

    2° – future posts in the next 4 days (with exclusion of the next 48 hours posts)

    at the moment I’m using this solution:

    FIRST LOOP

    <?php query_posts('showposts=-1&order=ASC&cat=-14,-10'); ?>
    <?php if ( have_posts() ) { while ( have_posts() ) : the_post(); ?>
    <?php static $ctr = 0;
    if ($ctr == "3") { break; }
    else { ?>
    
    <?php  $mylimit=60*60*24*7; //secondi * minuti * ore [* giorni]
     if ((get_the_time('U') <  (current_time(timestamp) - (get_settings('gmt_offset') * 3600) + $mylimit)) && (get_the_time('U') > current_time(timestamp)) ) {?>

    SECOND LOOP

    <?php rewind_posts(); ?>
    
    <?php query_posts('showposts=-1&offset=2&order=ASC&limit=5&cat=-14,-10') ; ?>
    <?php if ( have_posts() ) { while ( have_posts() ) : the_post(); ?>
    
    <?php static $ctr = 0;
    if ($ctr == "7") { break; }
    else { ?>
    
    <?php  $mylimit=60*60*24*7; //secondi * minuti * ore [* giorni]
     if ((get_the_time('U') <  (current_time(timestamp) - (get_settings('gmt_offset') * 3600) + $mylimit)) && (get_the_time('U') > current_time(timestamp)+48*3600 ) ) {?>

    The problem is that the page take more than 20 seconds to load and this fact is due to the loop used..

    Anybody can tell me something usefull to solve this issue ?

    thanks so much

Viewing 1 replies (of 1 total)
  • Why in The Loop you use
    <?php if ( have_posts() ) { while ( have_posts() ) : the_post(); ?>
    and not
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    (You use “{” instead of “:”)

    Thanks for your codes.

Viewing 1 replies (of 1 total)
  • The topic ‘display post in a range of date in the future’ is closed to new replies.