Refers to a mechanism built into the WP_Query class for querying the database for post data, including pages and CPTs, based upon post meta data.

learn more… | top users | synonyms

0
votes
0answers
16 views

how to insert post in wordpress with meta

How can I get the data from a table into the wordpress posts? I use this code but not corectly works... if (isset($_GET['SQL'])){ global $wpdb; $num; $rows = $wpdb->get_results("SELECT * from ...
1
vote
1answer
15 views

Sanitize Custom Field Value in Meta Query

I'm using the pre_get_posts hook with meta_query args to filter an archive loop by dates. Basically, there is a custom post type of "events", and my users type in a date as a custom field for the ...
1
vote
1answer
34 views

meta_query 'compare' => 'IN' not working

First of all, I know it's a duplicate. But, I could find those older answers helpful. I'm searching in posts through post_meta. Here's My Code: $args = array( 'numberposts' => -1, ...
0
votes
0answers
17 views

WP search in metadata post

In want to search by meta data value in post but I didn't succes. For example if I type "sound" I want to found "sounddiary" for example. Here my code: function custom_search_query( $query ) { ...
0
votes
1answer
56 views

WordPress meta_query not working

I am having issues with a meta query on a custom post type. The following arguments are set: $args = array( 'post_type' => 'wp_comp_entries', 'posts_per_page' => -1, ...
0
votes
0answers
15 views

meta query always fails even if data is correct

I've following query - $query = array( 'post_type' => 'accessory', 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => 'accessory-bike', ...
0
votes
1answer
42 views

How to delete only user meta value (not key) from usermeta table in wordpress?

I store multiple image in media library and save its id in wp_usermeta table. my metakey is 'images' and meta value in like '279,280,281'. Now I get the image from table like this: <?php $images = ...
0
votes
2answers
28 views

Wordpress altering my custom query, How to fix it?

I am querying for most popular posts by custom view count by using the custom query below, <?php $mostpopular_args=array( 'post_type' => 'post', 'orderby' ...
0
votes
1answer
17 views

Getting attachments by meta value

I'm stuck at a very simple point: I need to get all attachments by a custom meta key (and value). I'm developing a short code, so it has to work on every possible page. What I've tried so far: $args ...
0
votes
2answers
38 views

WP_Query with multiple meta fields filter?

I have the following query but it is still returning results which include posts which have a meta value of 'deal'. Any Clues on what am i missing in this $args = array( 'post_type' => ...
0
votes
1answer
20 views

Calling Specific Pages with wp query Part II

I'm making one page website and I added a custom field on "Page" post type that asks "Use this page as a section:" Yes or No(with dropdown). I called all pages on template-onepage.php(custom template) ...
0
votes
0answers
12 views

Querying sanatized data with meta_query in Wordpress

I asked this question over at SO yesterday, but I see now that this is the right place for it to live. After Googeling this for a while, I've found that this should work cite, but I don't seem to get ...
4
votes
2answers
160 views

Execute a large WP_Query with many “AND” Meta_Queries?

I have a custom post type product. Visitors can search products with many filters. They can set the color, the size, the price, etc. The details of the product are stored with Advanced Custom Fields ...
0
votes
2answers
48 views

wp_query check if integer exists in custom field's array

I'm using a wp_query to find custom posts that have a specified numeric value inside of a custom field. That custom field's value is an array of numbers (IDs of selected posts using Advanced Custom ...
0
votes
0answers
40 views

Build a query in wordpress , showing Post with Meta

wanted to build query to fetch, meta with Sticky = true. I have used , WCK plugin, https://wordpress.org/plugins/wck-custom-fields-and-custom-post-types-creator/ and created , "thumb" and "sticky" ...
1
vote
1answer
46 views

Get attachment by meta_key value

I need to get the attachment (will be only one per post) associated to a post with meta_key wpcf-legislacion-gratis (not matter the value the column has) by using a custom query using get_posts() ...
0
votes
0answers
22 views

Use more than one post meta inside the loop

I have custom meta like this: I want to select the post with both of these conditions are true for : 1- end_date = "some date" 2- st_date = "some date" Also I need it to select by title ...
0
votes
0answers
17 views

meta_query argument not working

I am trying to use WP_Query to search through posts BUT I want to also search by post_title as well, which is why I tried using meta_query in my arguments array. I want to actually do more than just ...
0
votes
1answer
21 views

Using orderby with 2 meta keys

I can use orderby with one meta key in the WP_Query using following: 'orderby' => 'meta_value_num', 'meta_key' => 'my_key_1', However is it possible to use orderby based on the calculation ...
0
votes
2answers
47 views

get_users with Serialized Custom Meta Value

I'm attempting to use get_users to select users with only a certain meta value. In this case the meta key is extraInfo but the the values are in a serialized array. Can I pull users out like this? ...
0
votes
0answers
135 views

ACF Relationship Field Search Filtering

I am trying to assign relate posts using the ACF relationship field. It has typeahead search to search by post titles. I would like to add meta_data search to the ACF relationship search. This ...
1
vote
1answer
103 views

WP Query Args - Title or Meta Value

How do I query by meta_value or title? If I set meta_values, $args['meta_query'] = array( 'relation' => 'OR', array( 'key' => 'model_name', 'value' => $thesearch, ...
0
votes
1answer
16 views

Is there any difference between below WP_Query code snippets?

Below code return the same results. Is it any difference between them and if it is then which one is better? code snippet 1: $args = array( 'post_type' => 'product', 'meta_key' => ...
0
votes
0answers
30 views

Get closest event where meta_key field is an array

I have a custom post type called "Event", which contains a repeatable date field _cmb2_date . I have a function which prints out posts: function post_style_6($args) { global $post; $the_query ...
0
votes
2answers
42 views

Get meta info related to current post

I'm trying to get the meta info by key rw_related_link for each post but my code is wrong since instead get the ones related to the current post I got the same in all post and that's wrong. This is ...
1
vote
2answers
35 views

Query posts if meta key starts with

I need to find posts with a meta key that starts with the current year + the current month (i.e. 201502), but the actual value could also contain any day within that month (i.e. 20150214). The ...
1
vote
1answer
68 views

How to order a post type with meta_value_num and if meta_value_num does not exist then order by date

I want to order a list of post on basis of ratings. I have used meta key "wp_ratings" for storing the rating value in wp_postmeta table. Now I want to sort all posts . If a post does not contains the ...
0
votes
1answer
41 views

add_query_arg to compare and display events from a certain date

I have archive-events.php file that sorts custom post type 'events' via WP_Query using custom field that is date formatted YYYYMMDD (20150215) like this: $args = array( 'post_type' => ...
0
votes
0answers
35 views

get_post_meta doesn't work with variable

The $event_count variable doesn't prints anything, what am i doing wrong? global $post; $event_count = get_post_meta($post->ID, 'eab_event-bp-group_event', true); $args = array( 'post_type' ...
1
vote
1answer
75 views

Any number in meta key (wp query)

I have such a query. The field modules_%_text is advanced custom fields flexible field where % should stand for ANY ROW number, it seams that it should work like that, however it's not. What i'm doing ...
0
votes
1answer
60 views

Sorting posts by ACF field

I am trying to sort posts by the 'prempost' ACF field, but it's not working (just shows default order). Can anyone see where I'm going wrong? ACF support suggested that I use http_build_query, which ...
0
votes
2answers
132 views

Filter query based on date in custom field

I have a custom post type jobs and custom field with key expiry-date which the user enters the date after which the post will no longer be displayed. Here's my code so far... $loop = new WP_Query( ...
0
votes
0answers
15 views

how to create advanced search [duplicate]

I'm really stuck in this and i cant find any tutorial or article about this topic. How about if we have this pattern for search: [country] AND [category1 OR category2] AND [city1 OR city2] AND ...
0
votes
0answers
30 views

How build search with filleting custom taxonomy and custom fields

I wanna explain about my search box, actually what i want to make. Ive a search input and few check boxes to filter the search result. i need to search like this : [Country1] AND ( [venue1] OR ...
1
vote
2answers
95 views

Custom post type archive with rand and meta_value

I have a custom post type that have a meta_key custom_meta_sponsored that owns alphabetical values. "X" means post doesn't sponsored. I want to show the archive page in custom order, sponsored first ...
0
votes
0answers
43 views

WP_Query with meta_value_num and meta_query not paged correctly

I have a strange thing with my WP_Query, where isn't paged correctly. $args=array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $limit, // 10 ...
0
votes
0answers
20 views

Meta query not returning results even though the sql contains the information

My page is not returning any results for my meta_query, just spits out the content in chronological order without applying the meta search. I am hoping you are able to assist. PS - This post has ...
0
votes
1answer
49 views

Comparing a field with several values at once with meta_query

I'm comparing the trip_region custom field of my trip CPT to the first element of an array: $filter_region[0]. Howevere I may have more elements in that array and I need to select trips whose ...
1
vote
1answer
54 views

Advanced Meta Query for Large Calendar Website (12k+ posts) (175k+ wp_postmeta rows)

The Problem On a site I built, I opted to use custom fields instead of a calendar plugin to organize my posts in a "calendar". In the beginning this seemed like the most logical way to accomplish ...
0
votes
1answer
70 views

Display Users from two roles in one list

I asked a question a few days ago (link) about a problem I encountered with WP 4.1 and a WP_User_Query I ran with a custom meta array. My current code worked until I upgraded to 4.1: if( ...
0
votes
1answer
68 views

shortcode order for event custom post type

ok im working on a website using post type event with post_meta event_start_date, i created a shortcode and everything is displaying fine except for it displaying in order, it seems as its not ...
0
votes
1answer
72 views

Post Query not working after updating to 4.1

After updating to Wordpress 4.1 I've noticed one of my more complex post queries has stopped working. It's querying from an events post type and returning posts with a standard timestamp of after ...
0
votes
0answers
91 views

Query Posts with meta_query key in array

I am trying to query posts using meta_query to get a series of dates stored as an array in the key repeat_intervals. I am able to query the first date using the following: global $post; query_posts( ...
1
vote
1answer
143 views

WP_User_Query with meta_query array relation 'OR'

I just updated to WP 4.1 and a User_Query I was using is now returning 0 instead of the expected results. $pm = array( //'role' => 'program_manager', 'orderby' => 'display_name', ...
0
votes
0answers
26 views

posts_clauses : Filtering Posts by multiple meta posts issue

Im trying to write function to filter posts by country and language, but as I see here posts are not filtered and I cant detect where is the problem. This is my code inserted in beginning of my ...
0
votes
1answer
76 views

How to add follow functionality to multi-author wordpress site?

is there any way to add "follow" functionality to Wordpress ? so that every logged-in user can follow his favorite author and only can see post from authors that he followed them .. A possible ...
1
vote
1answer
72 views

Add custom fields to search

I want to add a custom fields ("introduction" and "ensavoirplus") to search of Wordpress, but the SQL code is not exact. I don't understand if i do a mistake or if WP don't can do this. But my attempt ...
1
vote
0answers
7 views

What's the best way to query for currently running Wordpress events [duplicate]

I have a custom post type 'events' which has two extra fields. start_date and end_date. Start date must be set but end date is optional. I want to show events that are upcoming (after today's date) ...
0
votes
1answer
61 views

query_posts() with multiple meta data comparisons

I have a bunch of posts belonging to category 6, each having the same meta fields. I'm interested in two fields in particular: "pce_monday_open" and "pce_monday_close", both of which have numeric ...
0
votes
1answer
125 views

Meta Query querrying several post types based on ACF fields is broken after update to WP 4.1

I was using the following arguments for a WP_Query for months: $args = array( 'post_type' => array( 'posttype1', 'posttype2', 'posttype3', 'posttype4' ), 'posts_per_page' => -1, ...