• I want to order posts that I get from 3 categories (ex A,B,C) in the same order (A,B,C). By default I get the newest post first

    Thanks

Viewing 1 replies (of 1 total)
  • I believe that this code will do what you want:

    function mam_posts_join ($join) {
       global $mam_global_join;
       if ($mam_global_join) $join .= " $mam_global_join";
       return $join;
    }
    function mam_posts_orderby ($orderby) {
       global $mam_global_orderby;
       if ($mam_global_orderby) $orderby = $mam_global_orderby;
       return $orderby;
    }
    add_filter('posts_join','mam_posts_join');
    add_filter('posts_orderby','mam_posts_orderby');
    
    $mam_global_join = " INNER JOIN $wpdb->terms ON ($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id)";
    $mam_global_orderby = " UPPER($wpdb->terms.name) ASC, $wpdb->posts.post_date DESC";
    query_posts('cat=32,65,58&posts_per_page=20');

    Of course, you need to supply your own categories and posts_per_page.

Viewing 1 replies (of 1 total)

The topic ‘Order posts by specific categories?’ is closed to new replies.