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' => '=',
),
)
);
My Answer:
$args = array(
'post_type' => 'schedule',
'posts_per_page' => -1,
'meta_key' => 'day',
'meta_value' => 'Sunday',
'meta_query' => array(
array(
'key' => 'ordernum',
'type' => 'NUMERIC',
'compare' => 'EXISTS',
),
),
'orderby' => 'meta_value_num',
'order' => 'ASC',
);
Rate this post
3 of 5 based on 2670 votesComments