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

1
vote
1answer
367 views

Use meta_query to get title of associated post

I have two post types that I've associated in one direction by assigning Post A as a custom meta field of Post B. I need to search based on the titles of Post A and return the associated Post B ...
0
votes
1answer
61 views

Meta query stopped working

The following query stopped working all of a sudden and I can't figure out why. <?php $today = date("Y/m/j"); query_posts(array( 'post_type' => array('events'), 'meta_key' => ...
0
votes
1answer
996 views

$wpdb query a post type within a specific taxonomy term while ordering posts by custom meta value?

I have a custom post type 'event', a custom meta field 'event_date' and a custom taxonomy 'locations'. I want to query $wpdb to retrieve posts in this way posts must be of the 'event' post type ...
3
votes
2answers
946 views

Query between two meta keys

I feel like I'm extremely close on this one but the query keeps on showing up empty. Basically, I'm trying to query the custom values between two dates. Records should be returned if the start date is ...
1
vote
0answers
333 views

Meta query with multiple custom fields for archives page ordering problem

I'm modifying the query for archives pages so that the posts showing up on year, month or day pages are queried by there custom field (start-date and end-date) and are sorted by custom star-date ...
0
votes
2answers
637 views

How to query posts based on lat-lng coordinate as post meta?

I'm planning a custom WordPress theme where the Custom Post Type (CPT) will have latitude and longitude coordinate as it's meta value. The latitude and longitude will be displayed as a Marker in a ...
0
votes
1answer
112 views

meta_query returning excluded result

I have a series of day slots per location, in a multicheckbox custom field. I have a search page where the user can select location, weekday desired, and activity type. Right now I just have 2 ...
2
votes
2answers
258 views

Trying to perform complex custom field query with order by set to field value

I've got two custom fields for event posts: event-start and event-end. When I'm querying for current events, I'd like to show any post where the event-start OR the event-end is greater than or equal ...
1
vote
1answer
403 views

Meta_query with or without value

I am using WP_Query to sorting the post by user input. The input contains meta value which is display in select type field. Normally when there is value inserted into the form, the wp_query working ...
1
vote
0answers
432 views

filter custom field values $min $max

The user needs to query posts by entering a $minPrice, $maxPrice and a category value. Here is my query which returns no results: function result() { $result = array( 'cat' => ...
1
vote
1answer
138 views

Query by multiple meta elements not seeming to work - wordpress is timing out

Trying to run a query that pulls: get me 4 posts or pages that are not in sticky_posts and have (my_featured_post = 1 AND photo-image_post_id > 0) OR (my_featured_post = 1 AND photo-image_page_id ...
2
votes
1answer
581 views

WP_Query() show posts that end later than today

I have a query as follows: $wp_query = new WP_Query( 'meta_key' => 'end_date', 'meta_value' => 'today', 'meta_compare' => '>=', 'post_type' => 'vehicle' ); ...
1
vote
0answers
444 views

filter search custom field query

I'm looking for way to filter search results. This is what I have so far a custom post type of "doctors" in each "doctor" post, there are numerous custom fields (male or female, location, ...
0
votes
3answers
88 views

Creating Custom Query

I've hit some sort of stumbling bock here, and I can't find my way over it. I'm trying to craft a custom WP query that searches for posts by country of origin, selecting multiple countries at once. ...
0
votes
1answer
2k views

How can I create a meta_query with an array as meta_field?

Here are the args for my query : $args = array( 'post_type' => 'news', 'meta_query' => array( array( 'key' => 'topics', 'value' => 'sports', ...
3
votes
3answers
2k views

SELECT max(meta_value) FROM wp_postmeta WHERE meta_key='price'… stops working when value is over 999

Overview: I am not trying to return a post. I simply want the single highest value for a particular meta_value across all posts... just the value itself. Details: I have added a custom meta_key ...
2
votes
1answer
489 views

WP_Query display next custom post from today's date

I have a calendar plugin that uses custom posts types to create events. There are several custom fields that allow me to create various and seemingly unlimited post queries. The one I'm currently ...
0
votes
3answers
160 views

Delist entries in the_loop

I am trying to add a delisting feature to my WordPress network. Posts which are delisted would not appear in post lists, but would still be visible if accessed directly. I've written a plugin that ...
0
votes
1answer
590 views

Meta query with timestamp using WP_query

I'm having a problem with an events system that I'm developing for a local roller derby leaugue. I have made a custom post type ('event') where a user can add a few different types of events ...
1
vote
2answers
797 views

WP_Query not working as expected for attachments and custom meta_query

If I use get_posts() like so I get a number of results with the value 1 for the my_key meta_key: $posts = get_posts( array( 'post_type' => 'attachment', 'meta_key' => ...
1
vote
2answers
281 views

How do I find if a page has a template?

So I'm doing a query like this: $the_query = new WP_Query( array( 'meta_key' => 'homepage', 'meta_value' => 'yes', 'post_type' => 'page', 'orderby' => 'modified', 'posts_per_page' ...
2
votes
1answer
582 views

How can I query all users who registered today?

I'm trying to use meta_query to return all users that have registered today : $args = array( 'meta_query' => array( array( 'key' => 'user_registered', ...
0
votes
1answer
361 views

Excluding posts by meta, and also keeping posts without the meta

edit: Think I managed to figure it out, check the answer right under here, or click the following link: http://wordpress.stackexchange.com/a/51175/15809 I've been trying to find a way to exclude ...
0
votes
2answers
1k views

Use have_posts() with array of post results retrieved by $wpdb->get_results

I don't know if I'm retarded, crazy or just plain genius or not, but I've decided to use tags as a way to link content site-wide (a big ol' many-to-many relationship website for archiving various ...
0
votes
1answer
358 views

WP_Query orderby meta key/value suddely stopped working

I have code that has been working for a long time which when a user clicks a button to order database results by name/value, it gets the results via AJAX from a page that does all the querying. I ...
0
votes
1answer
588 views

Displaying posts with only upcoming dates according their custom field date value

I got posts that have starting date as a custom field value. I'm displaying few of those posts in my sidebar in ascending order so that the post with closest starting date is shown first. This is what ...
1
vote
2answers
1k views

Using Query Posts With Multiple Post Types And A Taxonomy

I am developing a site that has two different custom post types; one of them is called Articles and one is called Sketchpad. Sketchpad is user submitted content that is assigned a custom taxonomy term ...
1
vote
2answers
1k views

How do I make a meta_query OR relation work? [closed]

Here's are wp_query args: $args = array( 'post_type' => 'sportpages' ,'post_status' => 'publish' ,'posts_per_page' => 1000 ,'post_parent' => 4738 ,'meta_query' => ...
1
vote
1answer
405 views

WP_Query filter and order by meta ordering by wrong joined table

I'm trying to both filter and order a Wordpress query using the meta_value, however the ORDER BY part of the query seems to be working on the wrong table. The query params here are: array(12) { ...
2
votes
1answer
397 views

Meta_query with relation 'OR' killing server CPU

function get_nb_offres( $typeOffre ) { global $type_bien_correspondances; $args = array( 'post_type' => 'annonces', 'meta_query' => array( 'relation' => ...
0
votes
1answer
883 views

filter custom post type by meta key in dashboard

I'm looking for a way to expand e customize more this topic how to filter post listing (in WP dashboard posts listing) using a custom field (search functionnality)? I've a custom post type in the ...
0
votes
1answer
76 views

Best way to sort estates and query them (for rent? yes/no. contains office space? yes/no)?

I´m building a real estate site where Estates is a custom post type. I want to be able to tick a checkbox or something similare on the edit page, where I can choose if the estate is for rent, if it ...
0
votes
1answer
344 views

Compare meta_query decimals not working right

I have a custom field named 'rating' that holds decimals from 1.0 to 10. I am trying use wp_query to get me all the posts with a rating of 8.0 to 10. What I have so far almost works perfectly but it ...
1
vote
1answer
45 views

How to let users choose where to search for posts?

I have no code to let you correct/see, I'm still in 'thinking stage'. What i would like to achieve is this: A real estate website with a few search functionalities. This new agency (REALLY NEW we have ...
1
vote
1answer
2k views

How to grab metabox value in wp_query meta_query key

How would I modify my WP_Query in order to get a custom meta box value instead of a custom field one like I currently do? This is how my query looks like: <?php $today = ...
0
votes
1answer
274 views

Drag and Drop Metadata Menu Order

I'm not sure this has been answered previously.. I have a frontend form where the user fills out a form that has dynamic fields where they can add more fields if they choose to. The jquery names the ...
1
vote
1answer
1k views

Plugin that would allow WordPress Authors to “follow” other Authors and query “Activity Info” from that

I have a WordPress blog that is all user based Authors that submit content and such. Currently in the site, you can view other authors profiles but basically just view their content from the ...
0
votes
2answers
115 views

Getting a custom post's custom field based on another custom post's custom field select

So I'm at my wit's end here. I've done this before plenty of times, but I think I have stared at this so much I am missing something. I basically have a custom post called locations. That custom ...
0
votes
2answers
357 views

Create an archive listing based on meta array

I've got an "event" custom post type, with a meta field is used for the event date. I've successfully created archive pages (year and month) based on the answer on a previous question (here). Now, I'm ...
2
votes
2answers
1k views

Archives for custom post type based on a “date” meta value

I've got an "Event" custom post type. Each post has a meta field for the actual event date, which cannot be the posts's publish date, as most all the event dates will be in the future. With that, I'm ...
0
votes
1answer
711 views

Difference between 'LIKE' and 'IN' in meta queries

You can use a variety of different comparison operators in meta queries, among which are 'LIKE', 'NOT LIKE', 'IN', and 'NOT IN'. What is the difference in use between LIKE and IN? Here's the ...
0
votes
1answer
392 views

Arrange Posts By Date In Order Of Closest To The Current Date

I have a list of events on a clients website that show in a sidebar. When viewing the homepage you see one event and if you're anywhere else on the site you see two events in the sidebar. I am ...
0
votes
1answer
276 views

Is it possible to compare the current time with a custom “start” and "end date

I need to be able to display a custom post type if the current date is between the start and end custom meta field dates. Here is my code so far, it seems to just be ignoring the query and displaying ...
1
vote
1answer
1k views

WP_Query last five posts, simply ordered by meta_value

I can't believe I'm asking this question. It feels like such a simple method, yet I've poured over the WP pages and dozens of similar questions to no avail, so here it is... I've got a WP_Query with ...
-2
votes
1answer
484 views

Too many if's and else if's ?? - Must be better way [closed]

Everyone on this forum has helped me tremendously. Thank you. I now have a page that functions the way I want it but my code seems to be cumbersome. To figure out a string to echo I have a long ...
-1
votes
1answer
101 views

294 Queries on Mainpage of Wordpress

I have 294 queries on my wordpress site. I checked using sql monitorand the maximum queries are to display count of a cities list custom field. Lets say there are 200 cities then 200 queries are ...
0
votes
2answers
54 views

Should I save this mulit dementional arary as one post meta?

I have several blocks of data to save into post meta, including 'file_property', 'workspace_property', 'user_property','access_type', 'usage_tracking'. Each block in itself is an array. Should I save ...
1
vote
1answer
498 views

Filtering by Post Meta Custom Fields - Performance

I could use some advise on how to structure my data for performance. I have a custom post type with a lot of custom meta data stored in the wp_postmeta table as a serialized array under one meta key ...
0
votes
1answer
776 views

Search by meta_query

I am building a Wordpress site with an events feature. The events page was made with custom post types. I want to make it possible for people to search/ filter events by dates. For example, they can ...
0
votes
1answer
1k views

Help With issue on pre_get_posts filter in taxonomy

I create a function to filter the taxonomy query with this code add_action('pre_get_posts', 'custom_taxonomy_query'); $option_taxposts_per_page = get_option('tax_posts_per_page'); function ...