Try…
add_filter("posts_orderby", "my_orderby_filter", 10, 2);
function my_orderby_filter($orderby, &$query){
global $wpdb;
//figure out whether you want to change the order
if (get_query_var("post_type") == "my_post_type") {
return "$wpdb->posts.post_title ASC";
}
return $orderby;
}
Related Posts:
- Using meta_query, how can i filter by a custom field and order by another one?
- query_posts with a custom post type, a meta_query and sorting by post date?
- Sorting multiple custom post types without a meta key/value pair by sort order
- Sorting the Loop by Taxonomy Value
- How do I query a custom post type with a custom taxonomy?
- Can the Next/Prev Post links be ordered by menu order or by a meta key?
- Get the ID of the latest post
- Return all custom meta data for one custom post type
- register_post_type sort order by title by default
- Sort custom post type list table by display name of a user id stored as post meta value
- WordPress post sorting with AJAX
- Custom Taxonomy Template Post List with Sort Order
- Column sorting with emtpy meta values
- Display Custom Post Type Fields
- Loading Custom Post Type Events into jQuery-based FullCalendar?
- Limit the post for differents custom post type in the same wp_query
- Custom Post type sort order not working in the admin area
- How to sort a table of custom posts by column containing custom field
- How to get the parent’s taxonomy?
- Loading post content in FancyBox
- Multiple templates for custom post type
- ascending order custom post type
- How to get only one category of custom post type?
- Used with meta_query in query_posts works slowly
- Query for posts in 2 taxonomies
- Display custom post types with custom date field value (before today) & order by custom date field
- How to dynamically build a multiple taxonomy query loop within a post type’s single loop?
- List custom post type by custom tax term as page title
- How to make in WordPress admin panel sortable column for the custom field, that count the number of page impressions?
- Multiple post type queries (with specific arguments for each)
- Custom post type ‘orderby’ => ‘meta_value’ not working
- How to rank custom post type from score points
- Custom query works but returns “Undefined Offset: 0”
- Combining sorted and random CPT
- What’s a better alternative to this code?
- How to query_post custom posts within default taxonomy?
- Default sort on admin columns with meta date hides draft posts with empty date value
- How to use custom taxonomies to reference complex relationships?
- Query Custom posts of same taxonomy as the post itself
- Conditional Query of Custom Post Type and custom taxonomy
- Show a Category X’s custom post type on Category X archive page?
- WooCommerce sort products by the actual product width(not the shipping width)
- How to edit this code to get the categories in achieve page?
- Category with post type pagination returns 404
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Different Ways to Query Custom Post Types?
- Listing all term items alphabetically / sorting loop
- query_posts adding extra code to homepage
- How to show only the most recent post on my custom post type archive?
- How to make WP_Query not to show irrelevant posts?
- What is the ID parameter for custom post types in query_posts?
- Loop for custom post types filtered by a taxonomy
- Custom post type, custom taxonomy, query posts only from taxonomy (children of)
- Querying multiple values from a single key
- Custom Post Type page sorts differently on different environments
- find custom post type post by searching its custom field with my string
- FacetWP paging custom wp_query
- Creating a “glossary” of WordPress posts of a specific post type
- Can’t change posts per page in WordPress Post Type Query
- Incorrect ordering of custom post type based on time
- List all posts in taxonomy term
- Query all post types but limit to parents
- Sort column on meta key and meta value
- Query Multiple Custom Post Types & Exclude a Taxonomy Term
- Custom loop request based on custom field
- Custom Post Type Query W/Category Dropdown
- Query all posts under one taxonomy? Why is my code not working?
- What’s an easy way of sorting custom post types manually?
- Custom Post Types Not Showing Up In query_posts Result
- Find Posts based on Child Post value
- Showing only posts from the current user who is logged in?
- returning the currect URL for nested posts
- How to order query results based on if a custom field has been populated, then the order by the date of the post?
- Sort custom posts by date and then by taxonomy
- Custom post type sortable columns when column value is from a custom database value
- Create a post automatically if search result has zero results
- Limit custom post type to the authors only on front-end!
- Posts per Page on custom Taxonomy Template
- How to sort post category using its Description
- Wp Query sort order from custom MetaBox
- minimize wp_query call to database
- sorting in wp query based on custom field value
- Use WP pagination functions on a custom page template
- Getting Custom Posts with Custom Taxonomy
- How to sort custom post’s category by id from the theme’s function.php?
- How do I get the posts from single page custom post type from a sidebar to display in a page?
- How to set class to “current-page” on the currently viewed single post within a CPT
- WordPress custom post type
- WordPress custom post type queries
- Query Distinct Taxonomies of Custom Post Type
- Custom Query With Multiple Meta Key Value
- Ordering custom post type by custom field without a title
- How can I list custom post by custom category?
- Advanced Custom Fields: query posts filtered by multiple field values
- WP Build-In Post selector for CPT
- How can I sort posts ascending by post title for a specific post type, but on a category archive template?
- Inserting two categories
- How to exclude certain portfolios from a loop
- How to get Custom post type by related category ID
- Assign a tag to custom post type using a query