orderby parameter not working in custom query

orderby does not accept the values ASC or DESC. These are acceptable values for the parameter order. Changing ‘orderby’ => ‘rand’ to ‘order’ => ‘ASC’ should be sufficient and should by rule work As already pointed out, if (have_posts() ): should be if ($the_query->have_posts() ): Apart from that little discrepancy, you code have to work … Read more

Filtered by a custom field, ordered by another

You are sorting it incorrectly. You will need to check for artist-status meta key with meta_query and sort by last-name metakey. Here is your query. $args = array( ‘post_type’ => ‘artist’, ‘posts_per_page’ => -1, ‘meta_key’ => ‘last-name’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’, ‘meta_query’ => array ( array( ‘key’ => ‘artist-status’, ‘value’ => ‘invited’, ‘compare’ … Read more

Querying with WP query using meta key price

‘meta_value_num’ – Order by numeric meta value (available with Version 2.8). Also note that a ‘meta_key=keyname’ must also be present in the query. This value allows for numerical sorting as noted above in ‘meta_value’. Try to use like this : $args = array ( ‘post_type’ => ‘product’, ‘post__in’ => $post_ids, ‘posts_per_page’ => -1, ‘order’ => … Read more

paginate_links() Change the order of links

You cannot do this with the default paginate_links() functions. Looking at the source code, there are no filters from which you can change the layout as you wish ALTERNATIVE SOLUTIONS Although you cannot do this by default, it doesn’t mean that you cannot get your desired output. Here is a couple of options to explore … Read more

WP_Query custom order and pagination

You want to orderby ‘date’ not by ‘meta_value_num’ because it is to order numerically. So if you were ordering items by their price, then you would want to use ‘meta_value_num’. The meta_key ‘news_date’ is most likely in date format. You should also cast the meta_value to DATE using ‘meta_type’ => ‘DATE’. $args = array( ‘post_type’ … Read more

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