Posted By

hussong on 09/19/10


Tagged

list wordpress events widget


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

VladNovo


List upcoming Events in Sidebar via PHP Code Widget


 / Published in: PHP
 

Gets the date, pulls a list of upcoming events (posts from cat 6) and sorts by custom field \\"event_date\\" . Add to sidebar via PHP Code Widget.

  1. <?php $today = date ('Y-m-d'); ?>
  2. <?php query_posts('cat=6&showposts=5&meta_key=event_date&meta_compare=>=&meta_value='.$today.'&orderby=meta_value&order=ASC'); ?>
  3. <?php if ( have_posts() ) : ?>
  4. <ul>
  5. <?php while ( have_posts() ) : the_post(); ?>
  6. <li class="cat-post-item"><a class="post-title" title="Permalink to <?php the_title() ?>" rel="bookmark" href="<?php the_permalink() ?>"><?php the_title() ?></a></li>
  7. <?php endwhile; ?>
  8. </ul>
  9. <?php endif; wp_reset_query(); ?>

Report this snippet  

You need to login to post a comment.