order posts from older to newer with custom loop, and excluding ones
-
Hello all
Im having a problem while trying to create a template.
In home, i have a loop, who shows the 10 last post published.
Now, I need to sort from oldest to newest, but only display events that have not happened.
I mean, it’s for a events blog, I’m using the plugin “No Future Posts”, which allows to set the date of publication of the posts in the future, but mark them as published prior to the date.
The site is at: https://www.tocatas.de (white with orange boxes in the home).
I have the following code:
<?php $my_query = new WP_Query('showposts=10&cat=-26'); if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query- >the_post(); $do_not_duplicate = $post- >ID; ?> <?php //do not show older posts $expiredate = get_the_time('m/d/Y')." 00:00:00"; $secondsto = strtotime($expiredate)-time(); if ( $secondsto > 0 ) { ? > < div class="homeevento" > < ?php the_title(); ? > ... (the post) < /div > < ?php } //expiredate ? > < ?php endwhile; else: ? > < ?php _e('No upcoming Events'); ? > < ?php endif; ? >
So now the code shows the posts that have not happened (those who have not reached their date of publication), ignoring all others. But this showed me first the more distant, then the closer. I need to show first those ones who are closest to the current date.
When you modify the query by placing order=ASC, to show what I need, does not print anything on the screen. I tried using something like:
if ($ segundosquefaltan> 0): continue to see if that continued the loop of 10 posts, but neither worked.I hope you can help me, and hope you can understand my poor english
THX!
- The topic ‘order posts from older to newer with custom loop, and excluding ones’ is closed to new replies.