Retrieve select tag custom values from array and display them in current page with wp_query?

@Nick83, While I’m not trying to make the answer overly complicated, in order to do what you are attempting to do correctly I believe you’ll need to call WordPress via Ajax. My recommendation is the following: Create two ajax calls. The first gets the prices (without duplicates). The second takes whichever price the user chose … Read more

How to create dynamic value in WP_Query meta_query

You should be able to do what you’re trying to do. I think the issue may be that relation should not be contained in it’s own array. It should look like this: $prodPost = new WP_Query( array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 6, ‘paged’ => 1, ‘meta_query’ => array( array( ‘relation’ => ‘AND’, array( ‘key’ … Read more

How to search for meta_query LIKE or tax_query LIKE and grab these posts on search results?

Looking at WP_Tax_Query and WP_Meta_Query used by Wp_Query, they return their respective where clauses with an AND relation, and no hook or $args to change that behavior. Furthermore, the tax_query is computed before the rest of the main query so that it’s included in the main query in term_taxonomy_id IN (…) form. Also the WP_Tax_Query … Read more

change posts_orderby of the callback wp_query?

Ok, found the answer! I added ‘query_id’parameter in my query $query_string = sanitize_text_field( wp_unslash( $_GET[‘searchString’] ) ); $page_no = intval( $_GET[‘pageNo’] ); $posts_per_page = 9; $offset = ( $page_no – 1 ) * $posts_per_page; $search_args = array( ‘posts_per_page’ => $posts_per_page, ‘post_status’ => ‘publish’, ‘perm’ => ‘readable’, ‘s’ => $query_string, ‘offset’ => $offset, ‘query_id’ => ‘my_custom_ajax_search’, … Read more

wp_query show all values

The example below just changes what args is based on your 3 input fields. This eliminates the need to check for these values (and using “all” for value). I’m sure some combination of logical operators for compare and relation would do the job but this works too. if (isset($_GET[‘front-side-prop-search’])){ // test whether $city has a … Read more

WP_Query posts_per_page strange caching

Ok, finally I’ve found the reason. We must ignore sticky posts in WP_Query this way: $sidebar_related = new WP_Query([ ‘category__not_in’ => [$news->term_id], ‘post__not_in’ => [$post->ID], ‘posts_per_page’ => 4, ‘post_status’ => ‘publish’, ‘ignore_sticky_posts’ => ‘1’ ]); I hope it will help somebody.

Get specific ACF key and value from all posts – no access to DB

Why are you using $wpdb? This is a simple query, check the ACF docs for usage examples (https://www.advancedcustomfields.com/resources/query-posts-custom-fields/) <?php // args $args = array( ‘numberposts’ => -1, ‘post_type’ => ‘product’ ); // query $the_query = new WP_Query($args); ?> <?php if( $the_query->have_posts() ):?> <ul> <?php while( $the_query->have_posts() ) : $the_query->the_post();?> <li> <?php the_title();?> – <a href=”https://wordpress.stackexchange.com/questions/285872/<?php … Read more

posts_per_page returning only one post

You may please update your code as follows function blog_post_home_shortcode() { $query = new WP_Query( array( ‘post_type’ => ‘post’, ‘order’ => ‘DESC’, ‘post_status’ => ‘ publish’, ‘posts_per_page’ => 3 )); while ($query->have_posts()): $query->the_post(); $blog = get_the_title(); echo $blog; endwhile; wp_reset_postdata(); } add_shortcode(‘blogs_home’, ‘blog_post_home_shortcode’); Please check the above code and let me know if it works … Read more

Loop 3 posts column wise and continue the loop into same columns

If that col-4 class does what your example suggests it does, then just wrapping each post in col-4 would achieve the same effect: <div class=”col-4″> Post 1 </div> <div class=”col-4″> Post 2 </div> <div class=”col-4″> Post 3 </div> <div class=”col-4″> Post 4 </div> <div class=”col-4″> Post 5 </div> <div class=”col-4″> Post 6 </div> Then you … Read more