How to show category only if assigned
-
I’m trying to show the category assigned to search engine results, with the desired output as:
Posted in Category | Tags: Tag A, Tag B
Of course, I don’t want that text “Posted in” to appear if there is no category, and I don’t want the divider character either in that case. I’ve tried the following code, but it produces strange results:
<dl class="entryList"> <?php while (have_posts()) : the_post(); ?> <dt id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></dt> <dd class="postmetadata"><div class="asideBlock date"><?php the_time('F jS, Y') ?></div><?php the_excerpt() ?><?php if ( in_category( 'Advertising', 'Design', 'Web', 'Tools', 'Marketing', 'Branding' )) echo the_category('Posted in ',', ',' | '); ?><?php the_tags('Tags: ', ', ', '<br />'); ?> </dd> <?php endwhile; ?> </dl>
What am I doing wrong?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘How to show category only if assigned’ is closed to new replies.