Different post sort order within different categories

I need to give each post a unique post order for multiple Categories (per post) it is in. I can imagine a solution using custom fields whereby for each Category there is a corresponding custom field for the order. E.g. Categories: Playlist1 Playlist2 Playlist3 Custom fields for the post: Playlist1_Order Playlist2_Order Playlist3_Order This method is … Read more

How to query_posts using meta_query to orderby meta_key AND have a secondary sort by date?

I’ve been troubleshooting an issue over the past few days and keep going in circles. Could really use a fresh pair of eyes to help me answer this question… So I’m working with a wordpress site where posts have a few custom fields relevant to the query I need to run: “post-expired” and “my-sort-order”. When … Read more

ORDER BY custom field value

Based on example here https://make.wordpress.org/core/2015/03/30/query-improvements-in-wp-4-2-orderby-and-meta_query/ I’d like to modify the query $q = new WP_Query( array( ‘meta_query’ => array( ‘relation’ => ‘AND’, ‘state_clause’ => array( ‘key’ => ‘state’, ‘value’ => ‘Wisconsin’, ), ‘city_clause’ => array( ‘key’ => ‘city’, ‘compare’ => ‘EXISTS’, ), ), ‘orderby’ => ‘city_clause’) ); to be able to get all posts where … Read more

Sort admin menu items

On a related note to “Changing the Order of Admin Menu Sections?”, I’m looking for a way to alphabetically sort the entries in each sub-section of WordPress’s admin area. Currently, whenever a new plugin is added, its entry will appear in a seemingly random location under Settings / Tools / Plugins, and it’s often hard … Read more

Using meta_query, how can i filter by a custom field and order by another one?

With the following code (in functions.php) my posts (of CPT event) are ordered by _end_date instead of _start_date. What’s the proper solution to this as of WP 3.1.3? Of course I’d like to avoid using deprecated meta_key. add_filter( ‘pre_get_posts’, ‘my_get_posts’ ); function my_get_posts( $query ) { if ( is_home() ) { $query->set( ‘post_type’, ‘event’ ); … Read more