Questions tagged [meta-query]

103 questions
40
votes
2 answers

meta_query, how to search using both relation OR & AND?

Resolved: See answer below. I have a custom post type called BOOKS. It has several custom fields, named: TITLE, AUTHOR, GENRE, RATING. How do I fix my meta_query code below so that only books that have the search word in the custom fields: title,…
Angelica Santibanez
  • 1,321
  • 1
  • 9
  • 10
8
votes
1 answer

wp_query and meta_query for repeater field values

I have a word press site with custom fields. I need to query a repeater field as a table. It looks like that: | param_1 | param_2 | param_2 | param_4 | 20 | 20 | 20 | 20 | 555 | 680 | 56 | …
matisa
  • 497
  • 3
  • 25
3
votes
2 answers

Wordpress meta query

I have created a theme with a custom post type of reports. I installed a rating plugin that interacts with this post type, allowing users to rate the reports. It stores the post rating in two fields, sum and count where sum is the total for all…
Hughes
  • 985
  • 2
  • 9
  • 29
3
votes
0 answers

Meta Query - Compare two meta values in one query

I was looking on another question , and thought of changing the original query to compare two meta_key values. This question deals with finding WC coupons that reached their usage limit. There are two values stored as post meta data: usage_limit…
Shir Gans
  • 1,976
  • 3
  • 23
  • 40
3
votes
0 answers

wordpress tax query and meta query together

Im trying to use tax_query and meta_query together to get posts. What I've read online doesn't work. Its for a CPT and posts. Ideally what I'd like to return is all posts and only upcoming events. At the moment I can only seem to return either one…
2
votes
2 answers

How to add "OR" relation in "tax_query" and "meta_query". Because default is "AND"

How to add "OR" relation in "tax_query" and "meta_query". Because the default is "AND" [query] => Array ( [relation] => OR [posts_per_page] => 3 [offset] => 0 [orderby] => post_date …
2
votes
1 answer

'$wpdb->get_results' posts display in separate ccs tables -need a single table

NOTE: I've edited the code below to reflect a way that NOW WORKS, thanks for the help! My query pulls all the data I'm asking for from my custom post and custom fields. The fields fill in and the rows and columns look good. But the css table is…
MARWEL58
  • 19
  • 1
  • 5
2
votes
2 answers

How to filter last one year custom posts by comparing acf custom field date value

I have to get latest posts from only last 12 months by comparing the acf custom field datepicker value $args = array( 'post_type' => 'news', 'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1, 'meta_query' => array( array( …
2
votes
1 answer

I have a problem with combining meta_query "OR' and "AND" relations

i want to create filter with meta fields i create meta fields with ACF plugin, i want to use or relation for some meta_field but they dont work, for example on filter i choose "Male" and "Female" for meta key trainer this show me no posts but one…
2
votes
0 answers

WordPress custom query for multiple meta key and meta value for search

I have Three DropDown with multi-selection. Also used AJAX for getting the data using WP_Query. Process: If I am select first OR any DropDown from the page then it will return a result. Then select the second DropDown then it will set the "AND"…
Nishant Patel
  • 335
  • 1
  • 5
  • 23
2
votes
1 answer

How to allow the URL to alter the query using multiple parameters?

I want to display data based on query parameters passed through URL: https://example.com/?make=nike&model=shox&colour=white&body_type=slim. I can browse "nike" stock by accessing https://example.com/?make=nike. I can browse "nike shox" by accessing…
Kris
  • 85
  • 7
2
votes
0 answers

WordPress: pre_get_posts action combine date_query and meta_query

In my WordPress project, I have gotten some problem. I have many categories. The categories have a child category name New product. Currently, I have used pre_get_posts to get the posts list in New product pages. If a post which have post_date >…
Oliver92
  • 21
  • 2
2
votes
1 answer

Meta query key with POST OBJECT (ACF) (post_title) in wordpress

I have big problem with my meta query. I would like to filter my posts, and I need query to compare post_title with my $_POST value. Code: function postsFilter(){ $args = array( 'post_type' => 'posts', 'meta_query' => array( …
ceki10
  • 91
  • 1
  • 13
1
vote
0 answers

How can I enhance the ZigZag-Indicator in MetaTrader Terminal 5 to include bars and points for visualizing ranges?

Title :Enhancing ZigZag-Indicator in MetaTrader Terminal 5: Visualizing Range with Bars and Points Question : I'm looking to enhance the functionality of the ZigZag indicator in MetaTrader Terminal 5 by visualizing the range between the highest and…
1
vote
0 answers

wp_query using set() for meta_query doesn't work in elementor/query/{query_id} hook

I was attempting to set the following code in the elementor/query/{query_id} hook. The meta fields were created using ACF. $meta_query = (array) $query->get( 'meta_query' ); $date_now = date( 'Y-m-d H:i:s' ); $meta_query[] = array( 'key' …
yaara
  • 11
  • 2
1
2 3 4 5 6 7