Refine/Filter WP_Query Posts with jQuery or Ajax

I think what you might be looking for is combination of a plugin like https://wordpress.org/plugins/query-multiple-taxonomies/ and hooking into pre_get_posts if you are looping a list of posts. That plugin is in use on http://theboatworksnews.com/ so you can play with the projects section/filters and see if that matches what you’re looking for.

How to select posts from one category but exclude posts in another category?

Use pre_get_posts to exclude the categories you don’t want to display in the loop. function exclude_posts_from_specific_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘cat’, ‘-2’ ); } } add_action( ‘pre_get_posts’, ‘exclude_posts_from_specific_category’ ); Or create a new WP_Query and use the Category Parameters. <?php $args = array( ‘category__not_in’ => 2 , ‘category__in’ … Read more

Conditional to modify query results

here is the mysql query you can use to get the result having distance less then your value. SELECT * , pm1.meta_value as latitude, pm2.meta_value as longitude , (((acos(sin(([latitude]*pi()/180)) * sin((pm1.meta_value * pi()/180)) + cos(([latitude]*pi()/180)) * cos((pm1.meta_value * pi()/180)) * cos((([longitude] – pm2.meta_value)* pi()/180))))*180/pi())*60*1.1515 ) as distance FROM wp_posts p JOIN wp_postmeta pm1 ON pm1.post_id … Read more

How to limit total number of posts in wp query loop?

You can use the found_posts filter to alter the number of posts WordPress reports finding from a query. add_filter( ‘found_posts’, ‘wpd_found_posts’, 10, 2 ); function wpd_found_posts( $found_posts, $query ) { if ( $query->is_home() && $query->is_main_query() ) { return 25; } }

Multiple instances of Featured Image Query

For both loops move <a href=”https://wordpress.stackexchange.com/questions/67673/<?php the_permalink(); ?>”> To after while ( $the_query->have_posts() ) : $the_query->the_post(); the_permalink() is template tag and as such generates what it does, based on global $post variable. In your custom loop it doesn’t contain the post you want until after $the_query->the_post() call.