The answer to both issues was pretty simple.
- Simply add an argument to WP_Query to limit to the current category
- Make sure that WP_Query doesn't run unless there's actually some sticky posts
It wasn't hard to ask WP to ignore stickied posts, too.
Like so:
<?php
// Get sticky posts
$sticky_ids = get_option( 'sticky_posts' );
// BEGIN Custom "sticky" loop
// If sticky posts found...
if(!empty($sticky_ids)) {
$args = array(
'post_type' => 'post',
'category__in' => get_query_var('cat'), // Get current category only
'post__in' => get_option('sticky_posts') // Get stickied posts
);
$sticky_posts = new WP_Query($args);
if ($sticky_posts->have_posts()) :
while ($sticky_posts->have_posts()) : $sticky_posts->the_post();
get_template_part('post-formats/content', 'sticky');
endwhile; endif;
// END Custom "sticky" loop
// Reset post data ready for next loop
wp_reset_postdata();
}
if (have_posts()) :
/* Start the Loop */
while (have_posts()) : the_post();
$format = get_post_format();
if (false === $format) {
$format = 'standard';
}
get_template_part('post-formats/content', $format);
endwhile; endif; ?>