Query set orderby meta_value_num
please note that there will be more than I've put a filter on get_terms_defaults to set the orderby to use the new term metadata. so by default it orders posts by their ranking meta_key value, is this a good approach or do you think is better to create a “ranking” mysql table to use it as index only to order the posts? ' DESC '; }} // それぞれの orderby の入った配列を , で連結した文字列にする $ orderby = implode (', ', $ orderby_arg); } return $ orderby; } ↓ もっと簡単にできた版 For problem #1: You should use this format for the date: yyyy/mm/dd and use 'orderby' => 'meta_value' instead of 'orderby' => 'meta_value_num' I think this is the only way you can sort the results by date in custom field. Examples with description.
How to query and order WordPress posts using meta_query parameter.
However, in trunk, the meta_value_num Two more things: first – it is not case sensitive, second – wildcard symbols @ are not necessary. If you Estou utilizando a ordenação meta_value_num para ordenar a partir de uma meta_key que vai o valor de alguns imóveis (o valor é colocado sem casas decimais, ex: 100000 (100 mil)). ‘orderby’ => ‘meta_value_num’, ‘meta_key’ => ‘_adforest_is_feature’, This only shows those posts that have that meta key – but I want to order first by the posts that have the meta key as 1 and then all posts that have it either as 0 or don’t have it at all. ‘meta_value’ – ‘meta_key=keyname’がクエリーに存在しなければならないので注意。アルファベット順でソートされる。 ‘meta_value_num’ – 数値として並び替える。こちらも’meta_key=keyname’がクエリーに存在しなければならないので In WP 4.5, this works--looks like 4.4 did not accept meta_value and meta_value_num for orderby yet. NOT LIKE – similar to LIKE just works in an opposite way – meta value mustn’t contain the given string. Estou rachando a cabeça com um problema que estou tendo com o Wordpress.