Conditions in wordpress loop
-
Hi guys,
I have a little problem using the wordpress loop. I need to display events so I request 5 post_per_page events and hide passed events. My probleme is when i use the loop, wordpress take 5 posts from the query and hide the passed events. Is there a way to query ONLY the coming events?
Here is my code!
<?php $args = array( 'post_type' => 'events', 'orderby' => 'event_date', 'meta_key' => 'event_date', 'order' => 'ASC', 'posts_per_page' => '5', ); query_posts( $args ); if ( have_posts() ) { ?> <ul class="list_elements"> <?php while ( have_posts() ) { the_post(); $event_date = get_post_meta($post->ID, 'event_date', true); $location = get_post_meta($post->ID, 'event_location', true); if (date("d/m/Y", $event_date) >= date("d/m/Y") ) { global $post; ?> <li class="clearfix"><a>"> <?php the_post_thumbnail("partners"); ?> <h3><?php the_title(); ?></h3> <p><?php echo date("d/m/Y", $event_date); ?> - <?php echo $location; ?></p> <img class="facebook_icon" src="<?php bloginfo("stylesheet_directory"); ?>/public/img/facebook_icon.png" alt="facebook_icon" width=16"" height="16" /> </a></li> <?php } } echo '</ul>'; } wp_reset_query(); ?>
Thanks for the help guys ! 🙂
[No bumping. If it’s that urgent, consider hiring someone.]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Conditions in wordpress loop’ is closed to new replies.