Multipe array in meta_input

In your 2nd code snippet, you’re redefining $post_args for each $movie. Try this instead: $post_args = array(); foreach($movies as $movie) { $i++; $post_args[] = array( array( ‘key’ => ‘title’ . $i, ‘value’ => $movie[‘title’] ), array( ‘key’ => ‘qty’ . $i, ‘value’ => $movie[‘qty’] ), array( ‘key’ => ‘desc’ . $i, ‘value’ => $movie[‘desc’] ) … Read more

How do I empty a specific meta_value for all users in PHP

You could specify the meta key in the user query so the results you’re getting back are only for users who have an existing field. For reference WP_User_Query custom field(user meta) params. $args = array( ‘role’ => ‘Subscriber’, ‘meta_query’ => array( array( ‘key’ => ‘old_meta_key_name’, ‘compare’ => ‘EXISTS’ ) ), ); $users_with_meta = new WP_User_Query( … Read more

query_posts, oderby meta_value & print “future” posts

I would suggest storing the date-times as either: Timestamp (to sort/compare by meta_value_num) ‘yyyy-mm-dd hh:mm (e.g. 2012-04-11 19:37) to sort/compare by meta_value Then the following will work (assuming you’re using timestamp): $now = current_time(‘timestamp’); $args = array( ‘post_type’ => ‘rides’, ‘posts_per_page’ => 3, ‘meta_query’ => array( array( ‘key’ => ‘date’, ‘value’ => $now, ‘compare’ => … Read more

Order by meta values

You can do this by just looking for release_date_db: function plugin_name_get_posts() { global $wpdb; $the_posts = $wpdb->get_results( “SELECT * FROM $wpdb->posts, $wpdb->postmeta WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id AND meta_key = ‘release_date_db’ AND meta_value >= 20120000 AND meta_value <= 20121231 ORDER BY meta_value ASC;”, ARRAY_A ); }

Problem with meta_value order after update

Try WP_Query() instead of query_posts() $args = array( ‘posts_per_page’ => 10, ‘meta_key’ => ‘t_count’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’ ); // The Query $the_query = new WP_Query( $args ); // The Loop while ( $the_query->have_posts() ) : $the_query->the_post(); echo ‘<li>’ . get_the_title() . ‘</li>’; endwhile; // Restore original Query & Post Data wp_reset_query(); wp_reset_postdata(); … Read more

Order by meta_key where value is serialized

Yes, it is possible, however your question is not really precise. What you experience is probably already that it is possible to sort by meta_key even the value of it is a string of some serialized data – it’s just that this is the standard binary sort and WordPress does not take care about that … Read more