Here we put the posts objects in the placeholder in the while loop.
$holder1 = $holder2 = '';//placeholders
if ( have_posts() ) {
$term = $_GET['taxo'][0]['term'];//get the home taxonomy term slug from the url
$termname = get_term_by('slug', $term , 'home'); //get the term object for latter use , eg the term name
while ( have_posts() ) {
the_post();
global $post;
$recommend = get_post_meta($post->ID,'recommended',true);
if(isset($recommend) || !empty($recommend) ) { //if it has recommended meta key
$holder1[] = array(
'pojb' => $post
);
}else{
$holder2[] = array(
'pojb' => $post
);
}
} // end while
} // end if
So we can use the placeholders to output the html in the same template:
<?php
global $post;
if(!empty($holder1) || !empty($holder2)){
//we loop $holder first as it has recommended meta key
foreach($holder1 as $v){
$post = $v['pojb'];
setup_postdata( $post );//use this so that you can access post object like we did in formally while loop
echo '<a href="'.get_permalink.'">'.get_the_title.'</a>';
//blah blah blah
}
//and loop the $holder2 for the rest of the posts
foreach($holder1 as $v){
$post = $v['pojb'];
setup_postdata( $post );
//
}
}else{
//html for no posts found
}
?>