Hello fellow wordpress gurus!
I have a real problem which I have not been able to resolve even after 4 hours of trying to get this to work.
In summary, all I am trying to do is limit the number of results from a query_posts query.
Whats unique about this query is that I am essentially building an event calendar in which I have gotten wordpress to correctly display event posts based on a custom field called "event_start_date" sorted by upcoming events showing up first and have gotten it to excluding any posts which are older than todays date.
While the code below works perfect now I just want to limit the number of results to just 3. THIS IS MY ISSUE.
I am guessing that this would involve combining query or filtering the results through an array but I am not not aware of how this is done.
If anyone would be so kind and just modify the code below so I know how to do this in the future I would greatly appreciate it!!!
Thank you so much for you help. Below please find the working code I need to modify to only present the top 3 upcoming entries.
<?php
//Get the metadata for each child page
$today = strtotime(date("m/d/Y"));
global $wp_query;
query_posts(array('meta_key'=>event_start_date,'orderby'=>meta_value,'cat'=>25,'order'=>ASC,'posts_per_page'=>-1),array('showposts'=>3)); if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php //Get all Events and run a check against current date
$show_date = strtotime(get_post_meta($post->ID, 'event_start_date', single)); if($show_date >= $today) { ?>
<div id="homepage-events-list-container-group">
<?php if(get_post_meta($post->ID, 'event_end_time', single) != ''){ ?>
<div id="homepage-events-list-container-left">
<div id="homepage-events-list-date"><?php echo get('event_start_date'); ?></div>
<div id="homepage-events-list-time"><?php echo get('event_start_time'); ?> - <?php echo get('event_end_time'); ?></div>
</div>
<?php } else { ?>
<div id="homepage-events-list-container-left">
<div id="homepage-events-list-date"><?php echo get('event_start_date'); ?></div>
<div id="homepage-events-list-time"><?php echo get('event_start_time'); ?></div>
</div>
<?php } ?>
<div id="homepage-events-list-container-right">
<div id="homepage-events-list-title">"><?php echo the_title(); ?></div>
<div id="homepage-events-list-excerpt">
<b><?php echo get('event_type'); ?></b> - <?php echo substr(get_the_excerpt(),0,115); echo '... ' ?></div>
</div>
</div>
<?php } ?>
<?php endwhile; endif; ?>