Basically, I want to show the items that have the tag "Featured" first, then show all the items that do not have the tag "Featured, and then paginate the results.
$featured = array(
'post_type' => 'aircraft-refueling',
'tag' => 'featured'
);
$not_featured = array(
'post_type' => 'aircraft-refueling',
'tag__not_in' => array('592')
);
Here is the pagination:
function pagination()
{
global $wp_query;
$big = 999999999;
echo paginate_links(array(
'base' => str_replace($big, '%#%', get_pagenum_link($big)),
'format' => '?paged=%#%',
'current' => max(1, get_query_var('paged')),
'total' => $wp_query->max_num_pages
));
}
I am not too familiar with PHP, but I am guessing that I need to merge the queries into a new query and then paginate that new query? Help is highly appreciated! If there is a better method, please advise as well.
EDIT: Here is my progress. I almost got it to work but I am getting an error with this code even though it looks fine to me...?
<?php
$featured = get_posts(array(
'post_type' => 'aircraft-refueling',
'tag' => 'featured'
));
$notfeatured = get_posts(array(
'post_type' => 'aircraft-refueling',
'tag__not_in' => array('592')
));
$mergedposts = array_merge( $featured, $notfeatured );
$postids = array();
foreach( $mergedposts as $item ) {
$postids[]=$item->ID;
}
$uniqueposts = array_unique($postids);
$posts = get_posts(array(
'post__in' => $uniqueposts,
'post_type' => 'aircraft-refueling',
'post_status' => 'publish'
));
foreach( $posts as $post ) :
setup_postdata($post);
?>
Then the standard query:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
// THE CONTENT
<?php endwhile; ?>
<?php endif; ?>