Sorting: custom query with orderby meta_value_num THEN by title

This is very crude but should sort your posts by year (meta_value) and then by title. It does depend on how the query is setup so it will only work with the query below or with similar ones. function alter_order_wpse_103181($order,$qry) { remove_filter(‘posts_orderby’,’alter_order’,1,2); $order = explode(‘,’,$order); $order = implode( ‘ ASC,’,$order); return $order; } add_filter(‘posts_orderby’,’alter_order_wpse_103181′,1,2); $q … Read more

get_posts works but new wp_query doesn’t

You forget $query->the_post(), which makes the same as setup_postdata(). Also you are using $post->ID inside the loop but $post is not current post object in the loop. You have also syntax errors; for example you pass thumnail to wp_get_attachment_image() instead of a string “thumbnail”, and pass name as orderby argument instead of the string “name”, … Read more

Custom conditions in wp query

That can’t be done, since its translated to sql query I don’t see that code executing any where. You’ll have to do what @s_ha_dum said. Do it the other way, its cleaner and readable.

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