I have a magazine front page that updates with every issue, and the front page shows the current issue posts which are stickied. So for example, this month all the posts are in a category titlted 'Issue 01' and next month, I will create 'issue 02' which will replace the 'issue 01' sticky posts on the front page.
I am trying to show the category name of the posts that are pulled out in the query but cant seem to do this outside of the loop (i only want to show it once at the top before the loop starts).
Here is my query to call the sticky posts and an attempt to show the category name which doesnt work for me…
<?php // Get Current Issue Articles $currentissueposts = array( 'posts_per_page' => 6, 'post__in' => get_option( 'sticky_posts' ), 'ignore_sticky_posts' => 1 ); $currentissue = new WP_Query( $currentissueposts ); if ( $currentissue->have_posts() ) : ?> <div class="the-header"> <h3><?php the_category(); ?></h3> </div><!-- #the-header --> <?php while( $currentissue->have_posts() ) : $currentissue->the_post(); ?> <a href="<?php the_permalink() ?>" rel="bookmark"> <ol class="current-index-container"> <li class="the-title"><?php the_title(); ?></li> <li class="the-author"><?php the_field('sub_head_1'); ?></li> <li class="the-subtitle"><?php the_field('sub_head_2'); ?></li> </ol></a> <?php endwhile; wp_reset_query(); endif; ?>
I've looked over docu in terms of single_post_title and get_the_category but can't seem to get it to work only once. Any help is much appreciated!