How to query woocommerce product by pricing? [closed]

$args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 10, ‘orderby’ => ‘meta_value_num’, ‘meta_key’ => ‘_price’, ‘order’ => ‘asc’ ); $loop = new WP_Query( $args ); echo ‘<form id=”checkme”>’; while ( $loop->have_posts() ) : $loop->the_post(); global $product; echo ‘<div>’; echo ‘ <input type=”radio” name=”products” value=”‘.get_the_title().'” >’; echo ‘<label>’ . woocommerce_get_product_thumbnail().’ ‘.get_the_title().'</label>’; echo ‘</div>’; /* echo ‘<br … Read more

WP_Query for a taxonomy with different taxonomy types

You can create a taxonomy query. Assuming that “curso” is the term slug, it would look like this: $query = new WP_Query( array( ‘post_type’ => ‘obras_en_curso’, ‘posts_per_page’ => 4, ‘tax_query’ => array( array( ‘taxonomy’ => ‘casa_unifamiliar’, ‘field’ => ‘slug’, ‘terms’ => ‘curso’, ), ), ) ); For more information, see: https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

WP_Query args to show posts from specific custom taxonomy

Taxonomy query doesn’t work without terms parameter. So you have to first query all the regions term then assign term ids to taxonomy query. Here’s the solution – $terms = get_terms( array( ‘taxonomy’ => ‘regions’, ‘fields’ => ‘id=>slug’, ) ); $args = array( ‘orderby’ => ‘date’, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, … Read more

get_template_part causes 500 error

The get_template_part() function takes filepath relative to the file it is called in. Do you have a folder called ‘content’ which contains a file content-posttype.php? is the ‘content’ folder located in the same folder as this php file you are calling get_template_part() in? Also, you can modify your while loop as follows: while ( $postsQuery->have_posts() … Read more

Query post with meta value in set of values

Check This Will Work for you. $args = array( ‘post_status’ => ‘any’, ‘post_type’ => ‘any’, ‘numberposts’ => -1, ‘meta_query’ => array( array( ‘key’ => ‘Asin_unique’, ‘value’ => array(‘B006MWDNVI’,’B00BCMCIS2′,’B01ARRJFGA’), ‘compare’ => ‘IN’, ) ) ); $posts = get_posts( $args ); Help Link: https://rudrastyh.com/wordpress/meta_query.html

Multiple queries and performance – wp_query

No, the problem lies in the parts you didn’t put in your question, namely, the performance characteristics of a query are entirely down to this bit: I have new WP_Query ($taxonomy_query) and then I run an if while: That initial = new WP_Query([… is responsible for the entirety of the performance cost. By the time … Read more

Woocommerce pagination and result count after custom loop

You’re complicating things quite a bit with some of your query syntax, and WooCommerce actually discourages using WP_Query() to retrieve products. They even claim it can end up breaking down the road. I recently wrote an article on how to do what you want, complete with an example here: https://cfxdesign.com/create-a-custom-woocommerce-product-loop-the-right-way/

Is it possible to query a custom field where the value is between two fields?

I think it is pretty simple. I got the reference from here: https://www.advancedcustomfields.com/resources/query-posts-custom-fields/ $findNumber = 150; $args = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘photos-videos’, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘max_number’, ‘value’ => $findNumber, ‘type’ => ‘NUMERIC’, ‘compare’ => ‘>=’ ), array( ‘key’ => ‘min_number’, ‘value’ => $findNumber, ‘type’ => ‘NUMERIC’, … Read more

Why is WP_Query not displaying expected data?

You must change your date to an ordering like @ Krzysiek Dróżdż said or use meta_type options. I have tested with the string version. An example of meta_type $args is listed below. See also MySQL time variants /* Plugin Name: Meta Filter Plugin URI: https://wordpress.stackexchange.com/questions/304333 */ // ?XDEBUG_SESSION_START=304333 function wpse_304333() { echo ‘<p>wpse_304333</p>’; $args = … Read more

Admin Page Post Id wp_reset_postdata not working

Having attempted various work arounds the way I have this to work is to not use the_post(). WP_Query should still work but I have swapped over to get_posts(). $results = get_posts( $args ); foreach ( $results as $p ): $array[$p->ID] = $p->post_title; endforeach; return $array; Frustrating that this seems to be a problem with certain … Read more