Save queried result into database
You can save term meta using update_term_meta: update_term_meta( int $term_id, string $meta_key, mixed $meta_value, mixed $prev_value=”” ) https://developer.wordpress.org/reference/functions/update_term_meta/
You can save term meta using update_term_meta: update_term_meta( int $term_id, string $meta_key, mixed $meta_value, mixed $prev_value=”” ) https://developer.wordpress.org/reference/functions/update_term_meta/
Adding a if (has_posts() ) solved the issue which I forget to add. See the updated code in the question.
tax_query not working on custom post type
You can’t, WP_Query can sort by post meta value, but it can’t then use that value as a post ID, look up that post, then sort by a value on that other post. If you had a small number of posts, it could be done by manually sorting the results with PHP. Fundamentally, the data … Read more
SOLUTION <?php $args = array( ‘post_type’ => ‘product’, ‘post_status’=>’publish’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘sectors’, ‘field’ => ‘slug’, ‘terms’ => ‘garden’, ), array( ‘taxonomy’ => ‘season’, ‘field’ => ‘slug’, ‘terms’ => ‘winter’, ), ), ); $query = new WP_Query( $args ); echo $query->post_count ; ?>
Seems that WP_Query does not have the ability to query tags or categories. I ended up using the get_tags WordPress function and passed in the search term then merged the result with the WP_Query of the “places” endpoint. function placesSearch() { register_rest_route(‘placesdb/v1’, ‘search’, array( ‘methods’ => WP_REST_SERVER::READABLE, ‘callback’ => ‘placesSearchResults’ )); } function placesSearchResults($data) { … Read more
How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?
Prevent Duplicate Post Counted by Query
Instead of having $q->set( ‘posts_per_page’, 12 ) in the pre-get-posts function, I use the Read Settings ‘Blog pages show at most’ and that seemed to clear things up.
here is correct answer if someone need $aprel = get_queried_object(); /////////////////////////////////////////////////// $aprelpost = array( ‘post_type’ => ‘sikayet’, ‘post_status’=>’publish’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘sectors’, ‘field’ => ‘slug’, ‘terms’ => $aprel->slug, ), ), ‘date_query’ => array( ‘year’ => 2021, ‘month’ => 3 ) ); $aprelpost_query = new WP_Query ( $aprelpost ); $ap … Read more