I want to display my custom post type "portfolio" in alphabetical order and I got it working fine with this code:
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") == "portfolio") {
return "$wpdb->posts.post_title ASC";
}
return $orderby;
}
Unfortunately it affects also normal posts order list. I don't know why. How may I fix this? Thank you