Created
August 14, 2013 06:10
-
-
Save lunaroja/6228436 to your computer and use it in GitHub Desktop.
Wordpress Query using custom fields with Meta Box (http://wordpress.org/plugins/meta-box/) date fields to sort.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $query = " | |
SELECT * FROM $wpdb->posts | |
LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id) | |
WHERE ($wpdb->posts.post_status = 'publish') AND | |
($wpdb->postmeta.meta_key = 'event_start_time') | |
ORDER BY $wpdb->postmeta.meta_value ASC"; | |
$events = $wpdb->get_results($query, OBJECT); | |
?> | |
<?php if ($events): foreach ($events as $post): ?> | |
<?php get_template_part( 'loop', 'event' ); ?> | |
<?php endforeach; endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment