Do You need A meta query Param for orderby?

Do You need A meta query Param for orderby?

You do not actually need the meta_query param to use the orderby, instead it uses the meta_key param, which although by WP Codex is deprecated is has been established here: How do you use orderby with meta_query in WordPress 3.1? that orderyby still needs the meta_key.

How to define orderby meta _ value of custom field?

I tried orderby also by meta_value_numeric and meta_value, but in any case the results are being ordered by the publication date (as regular posts do). Anyone know how can this be done? You can define the meta key for orderby parameter using the old method (I tested on WP 3.1.1)…

Are there custom fields for the new meta _ query parameter?

As of this, some query parameters of custom fields like meta_key, meta_value were deprecated for the new meta_query parameter ( see here) I try to have a pretty simple query with the new syntax, query posts by a certain post_type (services) that contains a specified meta_key (order_in_archive)- this is going well as expected.

How to generate order by Meta key in WordPress?

Step 1 Assign whatever value you want to your meta key, let’s call it my_meta_key, for each post to generate whatever order you want. Step 2 You set meta_keyin your query to my_meta_key. This tells WordPress to query for posts that have that key.

How to query by meta value in WordPress?

This tells WordPress to query for posts that have that key. Step 3 Set orderbyin your query to meta_value_num. This tells WordPress to not only query posts with my_meta_key, but to also order numerically by that key. That query argument is the only place you will ever see or use meta_value_num. – MiloApr 25 ’17 at 18:21 2

Are there options for custom Advanced Query in wp3.0?

Aa you know, as of WP3.0 there are options for custom advanced queries, which is great. As of this, some query parameters of custom fields like meta_key, meta_value were deprecated for the new meta_query parameter ( see here)


How to nest a meta query in WP?

The meta_query parameter will actually be transformed into a WP_Meta_Query object, and the relation verification won’t go deeper in wp-includes/meta.php, and occurs just once in the top level: A possible solution for this is to build your own JOIN for this query.

How to create custom query with Meta key?

The main detail is: include meta_key, my code didn´t order unless meta_key is included, and that’s all: Here is the full code of a list of directors pictures order by director_weight: