Help with Single Cat Title Wordpress

efeezy

New member
Oct 5, 2007
5,250
136
0
50
I can't for the life of me figure out how to code this so when the single cat title pulls it's linked to that category.

This is the code which is pulling the category from the post

<h2><?php single_cat_title(); ?></h2>

I've tried everything I can think of to make that come up as a link to archive for it's particular category and nothing seems to do it. Here's the full code for what I'm working on.

<?php
$categories = get_categories('hide_empty=1');
foreach ($categories as $category) :
query_posts('showposts=3&cat='.$category->cat_ID);
if (have_posts()) : the_post();
?>


<!-- begin post -->
<div class="post">
<h2><?php single_cat_title(); ?></h2>
<div class="thumb"><a href="<?php the_permalink(); ?>"><?php dp_attachment_image($post->ID, 'thumbnail', 'alt="' . $post->post_title . '"'); ?></a></div>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>



<a href="<?php the_permalink(); ?>" class="readmore">Play Now</a>
User Ratings -<?php if(function_exists('the_ratings')) { the_ratings(); } ?>
</div>
<!-- end post -->

<?php endif; endforeach; ?>

</div>

This is the theme I'm using, and I figured it would do this automatically, but it's not. Mega News Theme..
See how "Advertising", "Blogging", "Fashion" are showing above the individual posts...that's what I'm going for. Any ideas?
 


Are you perhaps looking for this?

<?php the_category(', ') ?>

When you're in single page view, that will create a hyperlink to the category the post was created in.

Sonofabitch...thanks man. I'm a moron. That did what I needed. +rep
 
Sonofabitch...thanks man. I'm a moron. That did what I needed. +rep

I didn't know what it was off the top of my head, so all I did was open up single.php in the default theme and look for the "Posted in ..." to find where it said category. Looking at the default theme can be a good way to figure out some of the simple stuff.