WordPress Filtering Custom Post Type by Metadata and Search Heirachy
WordPress Filtering Custom Post Type by Metadata and Search Heirachy
WordPress Filtering Custom Post Type by Metadata and Search Heirachy
I don’t know if you’re looking for information or solution but this post might help you, especially the “Building a custom post meta box” section. The callback function is actually what you need. In this callback you need to run a loop that get posts from your Custom Post Type Demos and populate it into … Read more
I’m not sure if I get you right, but if you’re trying to query by multiple meta keys where the number of meta keys varies, then below is what I am using for the same purpose. Basically it adds meta query one after another if the corresponding input is existent. <form action=”” method=”post”> <input name=”item_name” … Read more
I did it this way: $name = explode(‘ ‘, $name); foreach($name as $string) { $args[‘meta_query’][] = array( ‘key’ => ‘name’, ‘value’ => $string, ‘compare’ => ‘LIKE’ ); } Which works good, but I’m not sure if that’s the best solution.
For multiple meta value you have to use “IN” $args = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘shows’, ‘orderby’ => ‘meta_value_num’, ‘meta_key’ => ‘start_date’, ‘order’ => ‘ASC’, ‘meta_query’ => array( array( ‘key’ => ‘show_location’, ‘value’ => array(‘second’,’third’), ‘compare’ => ‘IN’ ) ) ); // get results $the_query = new WP_Query( $args ); The IN comparison … Read more
Compare meta_query with a Regular Expression and do a less-than operation on it
The strtotime() function is what you need here: $date = date( ‘Y-m-d’, strtotime( $date ) ); //2015-04-10 with your example Note that you will need to do this when you save those values, not when running the query. You can’t convert data that’s already in the database on the fly when running a query. Edit: … Read more
How to use meta query for greater than value in array?
Meta Queries – should nesting work after WP 4.1?
Slow WP_Query with ‘OR’ on meta_query