WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: The Events Calendar] Generate array of events in date order (5 posts)

  1. justinstyle
    Member
    Posted 4 years ago #

    my events are in category 8, and i have been able to generate a loop of recent events for my homepage like this
    <?php $recent = new WP_Query("cat=8&showposts=3"); while($recent->have_posts()) : $recent->the_post();?>
    is there a way to order these from the date of the next event and forward, e.g 6th feb, 8th feb, 25th feb etc

    thanks

    http://wordpress.org/extend/plugins/the-events-calendar/

  2. ianidas
    Member
    Posted 4 years ago #

    Hey I've had this problem too, and appearently theres nothing on it anywhere (I've looked all over). I just got it though, heres the new query:

    <?php
    $time = date("Y-m-d H:i:s");
    echo($time);
    $wp_qry = "SELECT * FROM wp_posts, wp_postmeta WHERE wp_postmeta.meta_key = '_EventStartDate' AND wp_postmeta.meta_value >= \"$time\" AND wp_posts.id = wp_postmeta.post_id order by meta_value";
    $pageposts = $wpdb->get_results($wp_qry); ?>
    <?php if ($pageposts): ?>
    <?php foreach ($pageposts as $post): ?>
    <?php setup_postdata($post); ?>

    So that starts your loop, then the rest of the loop is the exact same. Take care.

  3. ianidas
    Member
    Posted 4 years ago #

    My apologies, take out the echo($time); , that was left in there from some debugging.

  4. ianidas
    Member
    Posted 4 years ago #

    Sorry for triple post: Just figured itd be easier to put the whole loop in at this point, here ya go:

    <?php
    $time = date("Y-m-d H:i:s");
    $wp_qry = "SELECT * FROM wp_posts, wp_postmeta WHERE wp_postmeta.meta_key = '_EventStartDate' AND wp_postmeta.meta_value >= \"$time\" AND wp_posts.id = wp_postmeta.post_id order by meta_value";
    $pageposts = $wpdb->get_results($wp_qry); ?>
    <?php if ($pageposts): ?>
    <?php foreach ($pageposts as $post): ?>
    <?php setup_postdata($post); ?>

    <div class="post" id="post-<?php the_ID(); ?>">
    <h2>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    <?php the_title(); ?>
    </h2>
    <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
    <div class="entry">
    <?php the_content('Read the rest of this entry »'); ?>
    </div>
    <p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>
    <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
    </div>
    <?php endforeach; ?>
    <?php else : ?>
    <h2 class="center">Not Found</h2>
    <p class="center">Sorry, but you are looking for something that isn't here.</p>
    <?php include (TEMPLATEPATH . "/searchform.php"); ?>
    <?php endif; ?>

  5. justinstyle
    Member
    Posted 4 years ago #

    If this is my full code, what should it now be?

    <div class="hpbottom">
    
    				<h3>Upcoming Gigs</h3>
    
    			        <?php $recent = new WP_Query("cat=8&showposts=3"); while($recent->have_posts()) : $recent->the_post();?>
    
    				<h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
    				<p><?php echo the_event_start_date(); ?></p>
    
    				<div style="border-bottom:1px dotted #2255AA; margin-bottom:10px; padding:0px 0px 10px 0px; clear:both;"></div>
    
    				<?php endwhile; ?>
    
    				<!--This is where you can specify the archive link for each section. Replace the # with the appropriate URL-->
    
    				<b><a href="http://www.thistlepark.com/?cat=8" rel="bookmark">View all upcoming gigs!</a></b>
    
    			</div>

    tried implementing your suggestion but it cause a break in the code somehow. thanks for the help

Topic Closed

This topic has been closed to new replies.

About this Topic