Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Build a custom query to get posts from future dates.
- $querystr = "
- SELECT wposts.*
- FROM $wpdb->posts wposts
- LEFT JOIN $wpdb->postmeta wpostmeta ON wposts.ID = wpostmeta.post_id
- LEFT JOIN $wpdb->term_relationships ON (wposts.ID = $wpdb->term_relationships.object_id)
- LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
- WHERE wpostmeta.meta_key = 'date'
- AND STR_TO_DATE(wpostmeta.meta_value,'%d/%m/%Y') >= CURDATE()
- AND $wpdb->term_taxonomy.taxonomy = 'category'
- AND $wpdb->term_taxonomy.term_id IN(5)
- AND wposts.post_status = 'publish'
- AND wposts.post_type = 'post'
- ORDER BY STR_TO_DATE(wpostmeta.meta_value,'%d/%m/%Y') ASC
- LIMIT 10
- ";
- $events = $wpdb->get_results($querystr, OBJECT);
- if ($events):
- foreach ($events as $post):
- global $post;
- setup_postdata($post); ?>
- <li>
- <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
- <p><?php the_excerpt(20)?></p>
- </li>
- <?php endforeach;
- else : ?>
- <li>Sorry, no events coming up.</li>
- <?php endif; ?>
- </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement