Display Category Name on Single Post
-
Hello–
I have the following structure:
Blog
|-> Kids
| ‘-> Post #1
|-> Students
| ‘-> Post #2
|-> Teens
‘-> Post #3I am trying to get the Category to display with an icon to the rss feed. I can get each of them to work except on the posts. The posts returns a null value for the Category.
For example:
Blog => Blog & /blog/feed/
|-> Kids => Kids & /blog/kids/feed/
| ‘-> Post #1 => (null) & (null)
|-> Students => Students & /blog/students/feed/
| ‘-> Post #2 => (null) & (null)
|-> Teens => Teens & /blog/teens/feed/
‘-> Post #3 => (null) & (null)I am trying not to code custom headings and feeds if possible, but I am getting a little frustrated. Here is the code:
<?php $imgurl = get_bloginfo('stylesheet_directory'); $rssurl = get_bloginfo('rss2_url'); $category = get_category( get_query_var('cat') ); if ( is_category()) { echo '<div id="blogheader" class="group"><h2>'. $category->name .'</h2><a rel="nofollow" title="Subscribe to the "'. $category->name .'" category" '. $rssurl .'href="http://localhost/bsfl/category/blog/feed/"><img src="' . $imgurl . '/images/rss_32.png"></a></div>'; } ?>
I don’t have a link to the site because it’s on a test server during redesign.
- The topic ‘Display Category Name on Single Post’ is closed to new replies.