Display wordpress posts with custom date meta value, ordered by this date, with a defined taxonomy


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $myrows = $wpdb->get_results("
  2. SELECT wposts.post_title, wposts.ID
  3. FROM $wpdb->posts wposts
  4. LEFT JOIN $wpdb->term_relationships ON(wposts.ID = $wpdb->term_relationships.object_id)
  5. LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
  6. LEFT JOIN $wpdb->terms ON($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id)
  7. LEFT JOIN $wpdb->postmeta ON(wposts.ID = $wpdb->postmeta.post_id)
  8. WHERE wposts.post_status = 'publish'
  9. AND wposts.post_type = 'concerts'
  10. AND $wpdb->postmeta.meta_key = 'DateConcert'
  11. AND CAST($wpdb->postmeta.meta_value AS DATE) > '".date("Y-m-d H:i:s")."'
  12. AND CAST($wpdb->postmeta.meta_value AS DATE) < '".date("Y-m-d H:i:s", $date2)."'
  13. AND $wpdb->term_taxonomy.taxonomy = 'Genres'
  14. AND $wpdb->terms.slug = 'Jazz'
  15. ORDER BY CAST($wpdb->postmeta.meta_value AS DATE) ASC
  16. ");

URL: http://www.kune-studio.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.