Forums › Forums › Search & Filter Pro › Sort order by custom field not working properly
Tagged: Post Types Order
- This topic has 7 replies, 2 voices, and was last updated 5 years, 11 months ago by
Anonymous.
Viewing 7 posts - 1 through 7 (of 7 total)
-
Trevor(Private) August 16, 2019 at 7:12 am #219094
That plugin, and others like it, will impact sorting in our plugin as it acts later in the WordPress page creation process. Post Types Order does have a hook you can use though, to stop it working under conditions that you set. It is discussed here:
Maybe like this (in your child theme functions.php file):
add_filter('pto/posts_orderby/ignore', 'pto_ignore', 10, 3); function pto_ignore( $ignore, $orderBy, $query ) { global $searchandfilter; $sf_current_query = $searchandfilter->get(12345)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { } else { $ignore = TRUE; } return $ignore; }
Where 12345 is changed to the ID of your search?
I am not sure if this is much the same, but simpler/shorter:
add_filter('pto/posts_orderby/ignore', 'pto_ignore', 10, 3); function pto_ignore( $ignore, $orderBy, $query ) { global $searchandfilter; $sf_current_query = $searchandfilter->get(12345)->current_query(); if (!((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()==""))) $ignore = TRUE; return $ignore; }
-
AuthorPosts
Viewing 7 posts - 1 through 7 (of 7 total)