Meta_query with key as an array
Meta_query with key as an array
Meta_query with key as an array
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
If I understood correctly, I believe this will help you to get what you’re after. I can’t verify it works, but reading it should give some guidance: function my_plugin_verify() { // ————————————————————————– // 1) I’m checking if the user is logged in if (!is_user_logged_in()) return false; // NOT VERIFIED // ————————————————————————– // 2) if he … Read more
If you want to get the post for an actor for example, there is different solutions, but in my opinion, the best is to use tag as actors names, or post meta. The current solution I give to you is using WordPress search system and try to find posts. // We try to get post … Read more
For the author single page $query = new WP_Query(array( ‘post_type’ => ‘books’, ‘meta_key’ => ‘author’, ‘meta_value’ => get_the_ID() // assuming you’re inside the loop )); while($query->have_posts()) { $query->the_post(); the_title(); } wp_reset_query(); For the books archive page // assuming you’re inside the loop $author = get_post(get_post_meta(get_the_ID(), ‘author’, true));
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
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 ); }
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
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
Check if meta_key exists in wp_list_pages