Questions tagged [meta-query]

103 questions
1
vote
0 answers

pre_get_posts with meta_query effects static pages in WooCommerce

I used a big part of this code to add a meta_query in the WooCommerce product query. I don't get any errors, but the products are NOT getting filtered by the meta. It still shows all products. function yl_custom_product_query( $query ) { //…
Yorlinq
  • 131
  • 14
1
vote
0 answers

How can I filter through my meta query via acf fields?

I have a group of posts that can select a custom field 'Partner Content'. These posts then select their post author. The post author is a custom post type that has a relationship field that selects the 'Partner Company' associated with the post…
1
vote
0 answers

How using the Meta Box plugin in Wordpress, to filter posts by the value of a post type field?

I'm using the Meta Box plugin to create custom post types and fields. There is a record type teachers, and I'm trying to display the lessons associated with him on the page of a certain teacher. The code looks like this: $queryArgs = array( …
Alexey
  • 11
  • 1
1
vote
1 answer

WP meta_query to get posts without some specific value when meta_filed is multiply

Can't find a solution how to query posts without some specific value of meta_field that have many values. The situation is: I'm adding user id's on posts when they perform some specific operation. Like this: add_post_meta($_POST['post_id'],…
1
vote
1 answer

How to use WordPress metaquery when meta_value is saved as serialized key/value

I am Working on WordPress project , which required me to manipulate the existing plugin's WP_Query On the front-end side , I have 3 Dropdown , in which 2 of them I have customizes with tax_query and using plugin's filter , I don't know how to…
Parthavi Patel
  • 739
  • 11
  • 28
1
vote
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', …
1
vote
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
  • 202
  • 2
  • 12
  • 41
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
  • 99
  • 8
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
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
  • 9,141
  • 22
  • 109
  • 221
1
vote
1 answer

Query posts based on an ACF repeater sub field custom taxomomy

I have a custom post type which lists a set of colours and the types of products they are available on using an ACF repeater. The intention is to list CPTs with the appropriate available colours on another page. The availability of a colour is set…
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