Forums

How to not show posts from yesterday and before? (4 posts)

  1. danilolaurindo
    Member
    Posted 5 years ago #

    Hey guys, I have this question for you all. Inside an <ul>. I draw a list of all the posts in the "Events" category. It shows at the top of the list, the closest event to the actual day and the next 7.

    Let's say the next event is at August 28. On August 29, I shouldn't have that event on the list. Right?

    I just don't know how to exclude those posts. Here is my piece of code for it:

    <ul>
    <?php query_posts('category_name=eventos&showposts=8&order=asc'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile;?>
    </ul>

    Thanks in advance!

  2. Samuel B
    moderator
    Posted 5 years ago #

  3. danilolaurindo
    Member
    Posted 5 years ago #

    Well, the plugin doesn't seem to suit my needs. This simple loop goes for just one of my pages, and it tells students about the upcoming events (I have EventCalendar running for that).

    I have ran through the Codex so I could learn more about the query_posts, but still haven't achieved much...

    This piece of code shows something around what I need:

    <?php $current_month = date('m'); ?>
    <?php $current_year = date('Y'); ?>

    <?php query_posts("cat=22&year=$current_year&monthnum=$current_month&order=ASC"); ?>

    The only difference is that I needed that the loop didn't show anything that belongs to past days. All events dated back to August 24 should not show up anymore.

    I could use the variable $day-1 to exclude posts, but then it would exclude only the posts from yesterday, not from the last week, or last month...

    Any other thoughts guys? :/

    ps.: Thanks Samboll

  4. danilolaurindo
    Member
    Posted 5 years ago #

    Anybody?

Topic Closed

This topic has been closed to new replies.

About this Topic