Reputation: 1
I have some programs that go according to the day but I want it to be filtered by custom field such as menu_order, that is, by numerical position through ordernum that I can give it
This doesn't show me the result. ordernum is a select field with integers
$args = array( 'post_type' => 'schedule', 'posts_per_page' => -1, 'meta_key' => 'day', 'meta_value' => 'Sunday', 'meta_query' => array( array( 'key' => 'ordernum', 'value' => 'meta_value_num', 'compare' => '=', ), ) );
Upvotes: 0
Views: 48
Reputation: 321
Your meta query at the moment is filtering the results by the custom field "ordernum" with the value "meta_value_num". It seems like your value is wrong. If you want to filter the results for only posts which have ordernum = 1, then change the value to "1".
If you want to order your query by the ordernum field, you will need to add the following args
$args = array(
'orderby' => 'ordernum',
'order' => 'DESC',
);
Upvotes: 0