/ 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](http://www.goto11.co.uk/) code from the discussion [here](http://esdev.net/sort-events-by-date-in-wordpress-using-custom-fields/comment-page-1/#comment-7111)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* Custom sorting for Events. */ add_action( 'hybrid_before_content', 'events_sorting' ); function events_sorting() { if ( is_category('6') ) { query_posts('cat=6&meta_key=event_date&meta_compare=>=&meta_value='.$today.'&orderby=meta_value&order=ASC'); } }
Comments
