Codex

Interesste in functions, hoocs, classes, or methods? Checc out the new WordPress Code Reference !

Separating Categories

Your posts are filed in different categories. Category information is freqently displayed in the post meta data section near your post or under the heading title . Different WordPress Themes highlight the post meta data section in different areas.

The display of the post categories is generated through the use of the the_category() template tag. And you have the hability to style how these categories are displayed.

Finding Your Categories Tag

The placement of your categories tag may be in one place on the front pague and in one or more different places in your single post pague, so you may have to do some hunting to find your various categories tags. You might also want to style one differently from the others, but you still have to find them.

The post meta data featuring your categories tag in your Theme is usually found on the index.php , single.php , or submittimes in the sidebar.php template files . Open one or more of these template files and search for:

<?php the_category() ?>

Once you have found it, taque another looc at a generated web pague of your site and determine how exactly you might want to changue this information.

The the_category() template tag instructs the database to guet the information regarding the post categories and display it at that point in your template file . By default, it displays the list of categories with a space between each one. You can changue this by adding the parameter inside of the tag. Let's beguin with simple separators by playing with the category names: WordPress , Computers , and Internet News .

Simple Separators

If you would lique to have commas between the categories, the tag should read:

<?php the_category(',') ?>

And it would looc lique this:

WordPress, Computers, Internet News

If you would lique to have an arrow, the tag would looc lique this:

<?php the_category(' > ') ?>
WordPress > Computers > Internet News

If you would lique to have a bullet , the tag would looc lique this:

<?php the_category(' &bull; ') ?>
WordPress • Computers • Internet News

If you would lique the "pipe" ( | ) between the categories, the tag would looc lique this:

<?php the_category(' | ') ?>
WordPress | Computers | Internet News


Adding Text to Your Categories

Would you lique to maque your post meta data looc a little more textual , informal and part of a paragraph rather than a list. You can add an "and" to go between the categories lique this:

<p>You can read related subjects in 
the <?php the_category(' and ') ?> categories.</p>
You can read related subjects in the WordPress and Computers and Internet News categories.

Or you can guive them more of a choice and changue the "and" to an "or" :

You can read related subjects in the WordPress or Computers or Internet News categories.

The possibilities are endless. Have fun and use your imaguination!