Yoast primary category query modification

I’m not sure this will fix it, but maybe try using the current category slug for the $current_category variable, instead of single_cat_title(), like so: $term = get_queried_object(); $current_category = $term->slug; This might help because the category_name parameter in WP_Query, despite its name, should be the term slug. single_cat_title() returns the displayed category title, not slug.

How to avoid bypass of search bar rules?

You want to use the pre_get_posts action to modify the search query on the server side. The pre_get_posts Codex have some examples to get you started. To target the main search query, try this: function my_search_filter( $query ) { if ( ! is_admin() && $query->is_main_query() ) { if ( $query->is_search ) { // Use $query->set(); … Read more

WP ForLoop to compare meta information of posts to determine what post to display

Your query should be something like this: $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 1, ‘meta_key’ => ‘<ACF FIELD KEY HERE>’, ‘meta_value’ => date( “Ymd” ), ‘meta_compare’ => ‘>’, ‘meta_query’ => array( ‘key’ => ‘<ACF FIELD KEY HERE>’, ‘value’ => date( “Ymd” ), ‘compare’ => ‘>’ ), ‘orderby’ => ‘meta_value_datetime’, ‘order’ => ‘ASC’, ); … Read more

Exclude a Woocommerce product from WP_Query

You can use “post__not_in” Parameter. add your products id in array which you want to exclude. $default = array( ‘post_type’ => ‘product’, ‘post__not_in’ => array(2024), ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘post_status’ => ‘publish’, ‘showposts’ => $numberposts ); if( $category != ” ){ $term = get_term_by( ‘slug’, $category, ‘product_cat’ ); if( $term ) : $term_name … Read more

WP_Query Taxonomy categories filtering

You can nest your tax queries. Just make sure you use OR as the first relation and AND relation on the nested tax queries. $filter_group_a = array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, ‘terms’ => $term_a, ), array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, ‘terms’ => $term_b, ), ); $filter_group_b = … Read more

WP Query Compare cutting off last 2 dates

It looks like your meta_query is nested within an extra array. Aside from that, the code looks valid. Hope this helps: $argsTwo = array( ‘post_type’ => ‘event’, ‘meta_key’ => ‘_event_information_year_select’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘_event_information_year_select’, ‘value’ => 1999, ‘compare’ => ‘>’ ), array( ‘key’ … Read more

Reload Query Loop When FacetWP Uncheck [closed]

I think the “initial” state being a shortcode is the root of your issue. I’m making a few assumptions to what your setup looks like: You have the [a-z-listing] shortcode as your “default” state for the FacetWP settings on this page. FacetWP and AZ Listings are not integrated (I don’t believe they are officially). Here … Read more