Custom query meta_value not working
-
Hi!
I have a custom post type with several meta fields. I need to output the posts on the page ordered by a meta value. Here is my query:<?php $query = new WP_Query(array( 'post_type' => 'message', 'posts_per_page' => 5, 'meta_key' => 'date', 'orderby' => 'meta_value_num' )); ?>
The meta_key ‘date’ is actually present in the wp_postmeta table. This date is a custom field and is unrelated with the date of publication.
But that query outputs 0 posts. None of the other meta keys also work. When I pass empty meta_key the query outputs the posts ordered by default.
What may be the problem here? Thanks!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Custom query meta_value not working’ is closed to new replies.