Getting the categories from the next post to display
-
Hello all.
I am working on a project for my company building a word press template. On the single.php page, they would like at the end of the post a section that would basically display the next post in line, so a link that says “Read what’s next” followed by the posts categories, the title and the excerpt. I have every working, but the categories, I have tried and searched for hours to find out how to do this, is it possible? my code below:
<div class="entrynext"> <div class="whats-next"> <?php next_post_link( '%link', "Read What's Next »"); ?> </a></div> <?php $next_post = get_next_post(); if (!empty( $next_post )): ?> <div class="categoryHeader"> Categories should display here </div> <h3> <a href="<?php echo get_permalink( $next_post->ID ); ?>"><?php echo $next_post->post_title; ?></a> </h3> <div class="entry-content"> <div class="entry-excerpt"> <h4> <?php echo $next_post->post_excerpt; ?> </h4> </div> <!-- .entry-excerpt --> </div> <?php endif; ?> <!-- .entry-content -->
Thanks 🙂
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Getting the categories from the next post to display’ is closed to new replies.