Order by summing multiple values

I wouldn’t use taxonomies or custom fields for this purpose. Every time you’re add one custom field for a query, you have to add a JOIN part for that query – it means that with 10-15 custom fields, you’ll get query with 10-15 joins – so such query will be very slow. But there is … Read more

Including metaboxes from custom post types in global search — continued

I’ve figured out a fix. First, to fix bad results for an empty search, I require that (!empty(get_query_var(‘s’)) Before setting the “meta_query” query variable in my plugin. I thought the fix would be with the posts_request filter, but it continued to replace select SQL_CALC_GET_ROWS wp_posts.ID with select SQL_CALC_GET_ROWS wp_posts.* Even when I replaced the * … Read more

Add more button if more 8 items

$countries is not a number, but w WP_Query instance, so you can’t compare it with a number… This means that you should replace this: if ($countries > 7) { with: if ( $countries->found_posts > 7 ) { It will check if there are more than 8 countries that match your criteria. This way you can … Read more