Getting blog pagination to work on page set as front page

Yes, you’re correct that on the static front page, we use get_query_var(‘page’) to get the current page number. And actually, the issue in question (“the number 2 isn’t highlighted“) happened because you used get_query_var(‘paged’) (note the paged) with the current arg for paginate_links(), which means you’re passing the wrong number. ‘current’ => max( 1, get_query_var(‘paged’) … Read more

Combine 2 arrays in a query parameter

This does not work because this is not how you merge two arrays: ‘post__not_in’ => get_upsell_ids(), [get_the_ID()] Instead you need to take those 2 arrays and combine them using array_merge, a standard PHP function: https://www.php.net/manual/en/function.array-merge.php Note that __not_in type parameters have a very high performance cost and do not scale, this query will be very … Read more

Tax Query only returns for the first of several terms

Related issue: Multiple relationship for multiple tax_query in WP_Query The issue here was that mixed multi-relationship lookups are only permitted using the term_taxonomy_ids field in the query, the above worked fine once switched like so: $params = [ “status” => “publish”, “tax_query” => [ [ “taxonomy” => “jewellery_metal”, “field” => “term_taxonomy_id”, “terms” => [ 36, … Read more

Single field to search for matches on post ID or meta values

Use this code instead- $args = array( ‘post_type’ => ‘shop_order’, ‘posts_per_page’ => ‘-1’, ‘post_status’ => array_keys( wc_get_order_statuses() ), ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘_billing_first_name’, ‘compare’ => ‘LIKE’, ‘value’ => $_GET[‘sc’], // you should escape this ), array( ‘key’ => ‘_billing_last_name’, ‘compare’ => ‘LIKE’, ‘value’ => $_GET[‘sc’], // you should escape this … Read more

WP Query ordering on a meta field for posts with a date in the future not ordering by datetime

The docs are a little vague in this area, but it should be possible to define your ordering value more succinctly: $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 5, ‘category__in’ => $postCategories, ‘meta_query’ => array( array( ‘key’ => ‘ordering_date’, ‘value’ => date(“Y-m-d H:i:s”), ‘compare’ => ‘>=’, ‘type’ => ‘DATETIME’, ), ), … Read more