<h1 class="page-title"><?php echo $title; ?> </h1> <div class="archive-description"><?php echo $description; ?> </div> <?php get_template_part('partials/archive', 'category-related'); ?> </header> <?php if ($paged < 2 && of_get_option('hide_category_featured') == '0') { $featured_posts = largo_get_featured_posts_in_category($wp_query->query_vars['category_name']); if (count($featured_posts) > 0) { $top_featured = $featured_posts[0]; $shown_ids[] = $top_featured->ID; ?> <div class="primary-featured-post"> <?php largo_render_template('partials/archive', 'category-primary-feature', array('featured_post' => $top_featured)); ?> </div> <?php $secondary_featured = array_slice($featured_posts, 1); if (count($secondary_featured) > 0) { ?>
/** * Helper for getting posts in a category archive, excluding featured posts. * * @param WP_Query $query * @uses largo_get_featured_posts_in_category */ function largo_category_archive_posts($query) { //don't muck with admin, non-categories, etc if (!$query->is_category() || !$query->is_main_query() || is_admin()) { return; } // If this has been disabled by an option, do nothing if (of_get_option('hide_category_featured') == true) { return; } // get the featured posts $featured_posts = largo_get_featured_posts_in_category($query->get('category_name')); // get the IDs from the featured posts $featured_post_ids = array(); foreach ($featured_posts as $fpost) { $featured_post_ids[] = $fpost->ID; } $query->set('post__not_in', $featured_post_ids); }
/** * Helper for getting posts in a category archive, excluding featured posts. */ function largo_category_archive_posts($query) { //don't muck with admin, non-categories, etc if (!$query->is_category() || !$query->is_main_query() || is_admin()) { return; } // get the featured posts $featured_posts = largo_get_featured_posts_in_category($query->get('category_name')); // get the IDs from the featured posts $featured_post_ids = array(); foreach ($featured_posts as $fpost) { $featured_post_ids[] = $fpost->ID; } $query->set('post__not_in', $featured_post_ids); }