Questions tagged [meta-query]

77 questions
1
vote
0 answers

WordPress query posts without ACF repeater subfields AND specific value

I have two custom post types, playlists and games. Playlists have a ACF repeater field, that contain games. My goal: I am trying to build a simple query, that gets all playlists that DO NOT have this game listed in the repeater field AND alll…
1
vote
0 answers

WP Filter Post Title by first Letter, (a b c d e f g)

WP Post Title Image I need some help with this, The goal is to filter the post titles by letters. If I click "E", It should only show all post titles that starts with "E". I am wonder if the 'key' for post title is actually 'post_title' I can't seem…
Jelly
  • 13
  • 2
1
vote
1 answer

What is the best way to append additional 'meta_query' array to WP_Query conditionally

I have the following function: function returnD($p, $t1, $t2, $t3) { $args = array( 'post_type' => $p, 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => $t1, …
Si8
  • 8,578
  • 20
  • 88
  • 201
1
vote
1 answer

Find other product with exact same title

Following code get products I need but it does not match exact tile (name), so sometime it get some unwanted product. $pname = $product->get_name(); $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => '5', …
MNSiw
  • 23
  • 4
1
vote
1 answer

WordPress meta query check the current users in meta value array

I am having trouble to query cpt for the current user if s/he is in the meta value array. query args $args = [ 'post_type' => $cp::get_module_cpt(), 'posts_per_page' => - 1, 'meta_query' => [ 'relation' => 'AND', …
Code Lover
  • 6,794
  • 18
  • 66
  • 129
1
vote
1 answer

How can I order a wp_query with date and then time

I am using Advanced custom fields with separate date and time fields for events. What I need to do is show all the events that haven't yet occurred. I have managed to show the events in order by date so far but what I need to do now is now have each…
1
vote
1 answer

Posts are not sorting based on the meta key values

Custom meta query is not sorting the posts correctly by meta keys. If I have subscription type then those posts should come first after that the posts for those meta key is not exist. I am trying the below code but it is not working…
kristen
  • 21
  • 4
1
vote
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( …
1
vote
1 answer

Get list of values, then all post titles with that value

I have a working wordpress loop which displays all posts of a certain meta_query value. The only issue is that the values are repeated. For example, if I have two posts with the value "Blue" then both posts appear in the loop, which makes "Blue"…
BlueHelmet
  • 339
  • 3
  • 12
1
vote
1 answer

How to orderby meta_key acf field populated with currency symbol and digits?

I'm Querying listings(custom post type) using WP_Query and ordering results by ACF meta field. The field contains price values with the currency symbol and comma separations like $100,000. Here is the $args I'm passing to the WP_Query. $args =…
1
vote
1 answer

Wordpress - WP Query : meta_query relation ignored

I need help with a WP_Query. I use the meta query argument using the OR and AND relations, but this argument seems to be ignored in the result of the query. Here is my code : $args = array( 'orderby' => 'date', 'order' …
Nicolas J
  • 43
  • 1
  • 8
1
vote
1 answer

Meta Query Returns Nothing when Too Much Data

I am doing a "find dealer" lookup for a company so that users can put in a zip code and a radius and find all the dealers within that radius. It seems to work fine until I get a couple thousand zip codes. I am passing in the array of zip codes to a…
Nate Beers
  • 1,277
  • 1
  • 12
  • 21
0
votes
0 answers

WP_Query Meta Query returning nothing

I am trying to filter the contents of a WP Query using a meta_query. I have a feeling it's to do with the saved value being a serialised array but I've tried a few fixes online to no avail. Should have all the info you need below in code comments. …
Daniel Vickers
  • 911
  • 1
  • 7
  • 26
0
votes
1 answer

How do I use a tax_query and a meta_query in wordpress succesfully?

This is the code I am using: $results = array( 'post_type' => 'score', 'tax_query' => array( array( 'taxonomy' => 'competitions', 'field' => 'slug', …
0
votes
1 answer

Show related posts using meta query in Advanced Custom Fields

I have an ACF field called sale_or_charter with three radio options – for sale, charter or new build. Each custom post type will have one of these values – I would like to then display related posts that have the same value for the sale_or_charter…
Mr Toad
  • 244
  • 2
  • 8
  • 27