Customized post loops

Let say I have one default post category and one custom category called “my_name”.

EDIT

Related posts

1 comment

  1. Here is the code.

    I don’t have the exact code right now but it helps a lot to you.

        $args = array( 
            'post_type' => 'post',
            'posts_per_page' => 20,         
            'orderby' => 'date',            
            'order' => 'DESC'
            );
    $loop = new WP_Query( $args );
    $catDefaultArray = array();
    $catBArray = array();
    foreach ($loop as $post) {
        if($post->post_category == "default"){
            $catDefaultArray[] =$post; 
        } else if($post->post_category == "B"){
            $catBArray[] = $post;
        }
    }
    
    $finalArray = array();
    $j = 0;
    for($i = 0 ; $i < count($catDefaultArray) ; $i++){
        if($i % 3 == 0){
            $finalArray[] = $catDefaultArray[$i];
        } else {
            $finalArray[] = $catBArray[$j];
            $j++;
        }
    }
    

Comments are closed.