Advanced orderby with multiple meta_query

I tried everything I could to try sorting within the WordPress functions, but was unable to get what I wanted. I ended up following PieterGoosen’s advice and do a usort(). Here is what I have now: WP_Query $args $args = array ( ‘post_type’ => array( ‘member’ ), ‘tax_query’ => array( array( ‘taxonomy’ => ‘group’, ‘field’ … Read more

Wp_query order by multiple custom fields?

$qry_args = array( ‘post_status’ => ‘publish’, ‘post_type’ => ‘event’, // Post type ‘posts_per_page’ => -1, // ALL posts ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘year’, ‘order’ => ‘DESC’ ); add_filter( ‘posts_orderby’, ‘filter_query’ ); $all_posts = new WP_Query( $qry_args ); remove_filter( ‘posts_orderby’, ‘filter_query’ ); function filter_query( $query ) { $query .= ‘, post_modified DESC’; return $query; } … Read more

How to order a post type with meta_value_num and if meta_value_num does not exist then order by date

You can pass a space-delimited set of columns to orderby argument of WP Query: $args = array( ‘meta_key’ => ‘wp_ratings’, ‘orderby’ => ‘meta_value_num date’ ); $query = new WP_Query( $args ); You can also pass an array of key => sort_order for more granular control, for example: $args = array( ‘meta_key’ => ‘wp_ratings’, ‘orderby’ => … Read more

Help With issue on pre_get_posts filter in taxonomy

Solved! I was using the wrong technique to create a custom query to my taxonomy instead of using the function above I create new function that use query_vars. Here is the code function taxonomy_posts_order($query) { global $browsetype; $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); if ( $query->query_vars[‘taxonomy’] == $term->slug ) { … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)