Questions tagged [meta-query]

77 questions
31
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,081
  • 1
  • 8
  • 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
  • 412
  • 3
  • 20
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
  • 835
  • 1
  • 7
  • 28
2
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,831
  • 2
  • 23
  • 36
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
  • 21
  • 2
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
  • 321
  • 1
  • 5
  • 22
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
  • 6
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
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
0 answers

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
  • 71
  • 1
  • 9
1
vote
1 answer

Search Meta data for a post that has a meta key that has multiple values in WordPress

I am facing an issue with the meta query for my CPT. I have multiple values for a single meta key stored as a string separated with the '|' sign. I want to run a meta query that compares each value numerically and if meta has the >= to searched…
Tariq Khan
  • 43
  • 7
1
vote
1 answer

Query Posts by Meta Value array count from Relationship field (ACF) on WordPress

I have a relationship field "assigned_brands" on Stylist Post type that returns an array of the associated Brands post type. I want to query based on the count of assigned_brands . For example I want to get only the the Stylists that have between…
1
vote
0 answers

logic in meta_query wordpress query

I'm currently building a pre_get_posts function that will do the following: Filter out from the filters that I have set up but also I need some date filtering logic, for example if I have a project that is from the 1st to the 15th as an…
paper123
  • 79
  • 6
1
vote
1 answer

Display posts between two dates meta_query wordpress

I have two custom fields (advanced custom fields) of "start_date" and "end_date", I want to filter the projects that are between the two given dates, here is what i've tried: array( 'key' => 'date_start', 'value' =>…
1
2 3 4 5 6