WordPress – Sort with related category posts first

I have a page where I’m displaying a list of posts that are related to the category of the page that I’m currently on. The working code for that is here:

$count = 7;
$terms = get_the_terms (get_the_ID(), 'filter' );
if(is_array($terms))
{
    $category_filter = array();
    foreach($terms as $term)
    {
        $category_filter[] = $term->slug;
    }

}else $category_filter=array();


$paged = get_query_var('paged') ? get_query_var('paged') : 1;

// Query Out Database
$wpbp = new WP_Query(array( 'post_type' => 'portfolio',
                                'posts_per_page' =>$count, 
                                'paged' => $paged, 
                                'tax_query' => array( 
                                               array( 
                                                   'taxonomy' => 'filter', 
                                                   'field' => 'slug', 
                                                   'terms' => $term 
                                                    )
                                                )
                                ) 
                        );

Now, instead of limiting the posts to the current category of the page that I’m on, I’d like to display those posts FIRST, and then the rest of the posts in my custom post type afterwards. How can I set up that orderby statement? Thanks in advance.

Related posts

Leave a Reply