Determine and echo cat # of single post
-
I am using the code shown to generate a list of all the single posts in a specific category, and it is working great.
<div class="otherarticles"><p>All Articles in this series:</p> <ul><?php global $post; $myposts = get_posts('category=7'); foreach($myposts as $post) : ?> <li><a href=<?php the_permalink(); ?>><?php the_title(); ?></a></li> <?php endforeach; ?></ul> </div>
what id like to have happen is that everytime a viewer is viewing a single post (thus using the single.php template) the code automaticly updates the category number generatign that code to match the category that single post is in. The only way I am able to achive this at this time is to create separate single-#.php files and use a conditional script on the single to redirect to that file, but that is a lot of work to change just one measly number in a file.
surely there is a very simple way to get what im wanting through some kind of code rather than a plugin.
- The topic ‘Determine and echo cat # of single post’ is closed to new replies.