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

Exclude authors IDs from WP_Query

exclude specific authors from WP_Query You can do it like so: $args = array( ‘author__not_in’ => array( 10, 3, 4 ), ); $posts_query = new WP_Query( $args ); But if you meant “from WP_User_Query“, then in WP_User_Query, you should use the exclude parameter, and that array(‘who’ => ‘authors’) shouldn’t be in meta_query: $args = array( … Read more

Appending to existing WP_Query’s meta_query if exists

You can use the WP_Query::get method to get whatever is in the meta query like this: add_action(‘pre_get_posts’,’add_another_meta_query’); function add_another_meta_query($query){ //Be sure to only use the main query on frontend if($query->is_main_query() && !is_admin()){ $meta_query = $query->get(‘meta_query’,array()); $new_meta_query = array(); //now, $meta_query has the meta_query if set (or an array) //check if the old version of meta_query … Read more

get_query_var always returns the default value

In WordPress, query vars are not what you think they are. They are the arguments for the global WP_Query object which processes the main page request. Check the docs for more information. What you need in that particular case is to check the $_GET parameters on the page load. For example: $scoretime = filter_input( INPUT_GET, … Read more

Check if searched number is within the post meta value

Assuming your “property-guests” taxonomies have names like “1”, “2”, “3”, etc.: <?php // Get the number of guests the visitor searched for $requiredGuests = $_POST[‘guests’]; // Get all terms in the “property-guests” taxonomy // (By default, this will only include terms that are assigned to something) $allGuestNumbers = get_terms(array(‘taxonomy’ => ‘property-guests’)); // Create a variable … Read more

Running multiple WP_Query

Your problem is here: foreach ($wqPort as $projeto) $wqPort is an object of type WP_Query, not an array. If you look at your PHP error log, you should be seeing warnings and notices for those lines Instead, use a standard post loop: $q = new WP_Query( [ .. args here … ] ); if ( … Read more

Should I reset $wp_query?

The query is right and its working. But should I reset something? Yes! Should I reset them both or just one of them, or is it fine like above? Neither! Your WP_Query object is self contained in $query, so there’s no reason to touch the $wp_query global variable, why would you? $wp_query represents the main … Read more

2 column recent post query not respecting float right [closed]

Try this <div class=”row”> <?php $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 3 ); $counter = 0; $_posts = new WP_Query($args); ?> <?php if( $_posts->have_posts() ) : ?> <?php while ( $_posts->have_posts() ) : $_posts->the_post(); $counter++ ?> <?php if ( $counter === 0 || $counter === 1) : ?> <div class=”col-md-6 float-left”> <div> <a … Read more