ORDER BY custom field value

You can create groups of meta_queries using specific compare operation on them, and since you want to order based in a single custom field, you can keep the order declaration dedicated to the single meta field. So: $q = new WP_Query( array( ‘meta_key’ => ‘population’, //setting the meta_key which will be used to order ‘orderby’ … Read more

multiple orderby in pre_get_posts action

As Milo said : $query->set(‘meta_key’, ‘wpcf-object-sold-status’ ); $query->set(‘orderby’, array(‘meta_value’ => ‘ASC’, ‘date’ => ‘DESC’)); // $query->set(‘order’, ‘ASC DESC’ ); // not needed Relevant link: https://make.wordpress.org/core/2014/08/29/a-more-powerful-order-by-in-wordpress-4-0/

Get current menu_order

If you have the post with an $id: $thispost = get_post($id); $menu_order = $thispost->menu_order; WordPress itself does not provide a function to get the menu_order, so you have to query the post-Object. If you are outside the loop, you can use the above function, however inside the loop you could also achieve this by: global … Read more

WP_Query orderby date not working

This will definitely work….It worked for me… $username = get_the_author_meta( ‘login’, $author_id ); $args = array( ‘post_type’ => ‘any’, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘suppress_filters’ => true, ‘tax_query’ => array( array( ‘taxonomy’ => ‘author’, ‘field’ => ‘name’, ‘terms’ => $username ) ) ); $query = new WP_Query( $args );

Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?

The Problem I think there’s a typo in there: The name of the filter is posts_fields not post_fields. That could explain why the title2 field is unknown, because it’s definition isn’t added to the generated SQL string. Alternative – Single filter We can rewrite it to use only a single filter: add_filter( ‘posts_orderby’, function( $orderby, … Read more

Custom post type – order field

When declaring your custom post type using the register_post_type function, you have to add ‘page-attributes’ to the support field, like in the following example: register_post_type(‘myposttype’, array( ‘supports’ => array(‘title’, ‘editor’, ‘page-attributes’), ‘hierarchical’ => false )); You’ll need to add any other supported meta boxes as well to the ‘supports’ field, see https://developer.wordpress.org/reference/functions/register_post_type/ for more information … Read more

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş