Return to Snippet

Revision: 32157
at September 19, 2010 22:56 by hussong


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

Initial URL

                                

Initial Description
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)

Initial Title
Custom filtering and sorting for events via functions.php

Initial Tags
wordpress, query

Initial Language
PHP