Order posts by ID in the given order

Starting in WordPress 3.5, the orderby parameter will allow the value post__in to sort by the order of the post__in parameter, just like in your example. It may not be ideal to wait or require 3.5+, but this will almost certainly be the best and easiest way to do what you’re looking to do. Here’s … Read more

How to get order of posts?

Found the answer from the WordPress docs. For what the query is ordered by, I use: global $wp_query; echo $wp_query->get(‘orderby’); For the order by which the posts are queried: global $wp_query; echo $wp_query->get(‘order’);

Sort posts by popularity/page views

The WP Postviews plugin is one of the most used to record post views. Then you can sort by amount by; <?php if (function_exists(‘get_most_viewed’)): ?> <ul> <?php get_most_viewed(); ?> </ul> <?php endif; ?> Or pass in the variables to the URL: http://example.com/?v_sortby=views&amp;v_orderby=desc Or even run a custom query that sorts by the post_meta value.

Query Posts in a Predefined Order

If the query is only for a small number of posts, then as linked to by Alex you can sort in php. However, this does not scale well. As suggested by Kovshenin – a better alternative is to use posts_orderby filter: $post_ids = array(83,24,106,2283,14); $args = array( ‘post_type’ => ‘post’, ‘post__in’ => $post_ids, ‘numberposts’ => … Read more

Secondary Sort (fallback) for WP_Query

It’s a quite simple revision to your current code. You can add multiple “orderby” values separated by a space. ‘orderby’ => ‘meta_value_num title’, This should keep the priority of sorting by your meta value, with a secondary sort of title.

How to Change the Categories Order in the Admin Dashboard?

Found an answer in this answer. add_filter( ‘get_terms_args’, ‘wpse_53094_sort_get_terms_args’, 10, 2 ); function wpse_53094_sort_get_terms_args( $args, $taxonomies ) { global $pagenow; if( !is_admin() || (‘post.php’ != $pagenow && ‘post-new.php’ != $pagenow) ) return $args; $args[‘orderby’] = ‘slug’; $args[‘order’] = ‘DESC’; return $args; } The order may be ASC or DESC, and the orderby can be: count … Read more

Sort posts by Date (DESC) and by Title (ASC)

You can pass an array to the query as the following example described in the Codex shows: $args = array( ‘orderby’ => array( ‘title’ => ‘DESC’, ‘menu_order’ => ‘ASC’ ) ); $query = new WP_Query( $args ); In your case will be something like this: /* Order Posts Alphabetically */ function prefix_modify_query_order( $query ) { … Read more

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