Why the pre_get_posts hook can cause apache stopped working?

As per this WPSE thread you are actually putting overload to the apache. That’s why it’s reacting like that. 🙂 So let’s cut the overload, use is_main_query() properly, and just add a simple conditional to your pre_get_posts hooked function: function e_exclude_posts( $query ) { if( !is_admin() && $query->is_main_query() && $query->is_tax(‘my_tax’) ) { $expired = g_get_all_the_expired_posts(); … Read more

Sort / Filter Queries

You can use either GET or POST requests to achieve that functionality without using any AJAX (which, in fact, does the same but uses JS to process requests). You need to add ?name_of_var=value after trailing slash on labels that link to different queries. Basically, your ‘Coca-Cola’ link has to look this way: site.com/products/?brand=cocacola After that, … Read more

Advanced Custom Fields Query with Different Values of the Same Key

One option is to fetch all of the posts to a single array and filter that array 50 ways. This would only generate the one query: $posts = get_posts(array( ‘posts_per_page’ => -1, ‘post_type’ => ‘school’ )); To filter your array you would do something like this: $this_state = “Texas”; $state_posts = array_filter($posts, function($results) use($this_state) { … Read more

Create custom query for search?

Have you check your result-set, what result you are getting in $query obj. another thing, there is no need to use ‘relation’ => ‘OR’, in meta query array, have a try with this as well. And instead of ‘numberposts’ use ‘posts_per_page’ this will help. 🙂 or you can remove the meta_query and make your $arg … Read more