Sort posts by meta value with get method

You’re not actually using the $_GET[‘orderby’]-value anywhere. What you’re doing in your code is ordering by the text_date-meta value, always. If you want to order by date by default, and when $_GET[‘orderby’] is set to default orderby-values or if $_GET[‘orderby_meta’] is set, order by those instead you need to do something like this: if (isset($_GET[‘orderby’]){ … Read more

Having trouble with settings terms as array in pre_get_posts

You need to modify the tax_query block of code like below- $q->set( ‘tax_query’, array(array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘term_id’, // Here it would be ‘term_id’ instead of only ‘ID’. ‘terms’ => $allowedCats, ‘operator’ => ‘IN’ // May be it would be ‘IN’ in stead of ‘NOT IN’. Cause you are passing allowed product categories. … Read more