Posted By

hussong on 09/19/10


Tagged

wordpress functions query sorting custom hybrid


Versions (?)

Custom filtering and sorting for events via functions.php


 / Published in: PHP
 

Uses action hook of the hybrid theme framework to launch function that modifies the query on the archive page for category 6.\r\n\r\nSorts by the custom field \\"event_date\\" and compares it to the current date.\r\n\r\nBased on goto11\\'s code from the discussion here

  1. /* Custom sorting for Events. */
  2. add_action( 'hybrid_before_content', 'events_sorting' );
  3. function events_sorting() {
  4. if ( is_category('6') ) {
  5. $today = date('Y-m-d');
  6. query_posts('cat=6&meta_key=event_date&meta_compare=>=&meta_value='.$today.'&orderby=meta_value&order=ASC');
  7. }
  8. }

Report this snippet  

You need to login to post a comment.