Title: Filtering bug fix
Last modified: May 9, 2019

---

# Filtering bug fix

 *  [copyjosh](https://wordpress.org/support/users/copyjosh/)
 * (@copyjosh)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/filtering-bug-fix/)
 * In /sermons.php,
    line 250: public static function fix_sermons_ordering( $query)
 *     ```
       public static function fix_sermons_ordering( $query ) {
       		if ( ! is_admin() && ( $query->is_main_query() ) ) {
       			if ( is_post_type_archive( 'wpfc_sermon' ) || is_tax( sm_get_taxonomies() ) ) {
       				$orderby = SermonManager::getOption( 'archive_orderby' );
       				$order   = SermonManager::getOption( 'archive_order' );
   
       				switch ( $orderby ) {
       					case 'date_preached':
       						$query->set( 'meta_key', 'sermon_date' );
       						$query->set( 'meta_value_num', time() );
       						$query->set( 'meta_compare', '<=' );
       						$query->set( 'orderby', 'meta_value_num' );
       						break;
       					case 'date_published':
       						$query->set( 'orderby', 'date' );
       						break;
       					case 'title':
       					case 'random':
       					case 'id':
       ```
   
 * Case “id” needs to be “ID” or wrap $orderby in a strtolower()…
 * Without this change, the option to sort by ID in the admin settings will not 
   work.

The topic ‘Filtering bug fix’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/sermon-manager-for-wordpress_688896.
   svg)
 * [Sermon Manager](https://wordpress.org/plugins/sermon-manager-for-wordpress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/sermon-manager-for-wordpress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/sermon-manager-for-wordpress/)
 * [Active Topics](https://wordpress.org/support/plugin/sermon-manager-for-wordpress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/sermon-manager-for-wordpress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/sermon-manager-for-wordpress/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [copyjosh](https://wordpress.org/support/users/copyjosh/)
 * Last activity: [7 years, 1 month ago](https://wordpress.org/support/topic/filtering-bug-fix/)
 * Status: not a support question