i have a query post :

$args3 = array(
    's' => urldecode($command),
    'orderby'   => 'type',
    'order' => 'ASC'

i want in result first show num1 post type results before num2 . what should i do ?

  • if i use 2 query i must use a lot of codes for limit number of posts but with 1 query i know how many post will show in result. in wordpress codex : codex.wordpress.org/Class_Reference/… there is a line for order by post type but there is no example...
    – Sajjad Sky
    Commented Aug 11, 2017 at 10:58

1 Answer 1


Here is solution for your prob dude

add_filter( 'posts_request' , 'modify_request' );
function modify_request( $query) {
    global $wpdb;
    if(strstr($query,"post_type IN ('review', 'directory')")){
        $where = str_replace("ORDER BY {$wpdb->posts}.post_date","ORDER BY {$wpdb->posts}.post_type",$query);
    return $where;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.