I’m not sure what values are stored as dates. If the date includes a time component, it would be very rare for stock dates to be exactly the same where title and menu order could come into play. I think the query is delivering what you asked for, even if it is not what you were expecting.
If you’ve double checked the underlying data and are sure the ordering is wrong, it could be other code is modifying the query ordering via a filter or action hook. Check the query object’s request
property and confirm the ORDER BY clause is as you specified.
Thanks for your reply.
I am sure product post type menu order values are non zero, I have order numbers.
actually the query is giving me by stock list by title. my question is is that possible to pass arguments in orderby meta_value_num and menu_order together? I tried its not giving any results.
is there any other way to do? I am bit stuck in there :(. Thanks in advance.
]]>So your query is not sorting by stock date either? Only by title? If the date is stored as a localized date string, depending on the format, ordering by meta_value_num may not have the desired effect. Also, if you also use the “meta_query” argument, it conflicts with “meta_key”.
There’s a number of reasons why ordering may not work. If you could post the query’s request property (the resulting SQL), someone could likely spot the conflict.
There are a couple drastic workarounds. One is to write your own SQL and use $wpdb methods. The other is to sort the return in PHP with usort(). This will be noticeably slower for any sizable list.
]]>