Forums

Changing the way the_category behaves? (3 posts)

  1. maybeithink2much
    Member
    Posted 4 years ago #

    Is there a way to change the behavior of the_category where, if a post is only in one category, it is displayed as:
    Filed under the category: WordPress.
    Under two categories as:
    Filed under the categories: WordPress and Software.
    Under three or more categories as:
    Filed under the categories: WordPress, Internet and Software.

  2. oriecat
    Member
    Posted 4 years ago #

    Hmm, I think that might be complicated.
    The code now <?php _e("Filed under:"); ?> <?php the_category() ?>
    the_category part only pulls the actual list of the categories and the Filed under comes from the other part. You can make it say anything you want, by changing it, but I don't know how you could make it behave differently depending on how many categories are actually used. But who knows, maybe it could be done.

  3. markjaquith
    Moderator
    Posted 4 years ago #

    Yeah, the_category() doesn't allow for that display. I wrote a plugin for you that can handle different separators between penultimate and last categories.
    WordPress Nice Categories Plugin

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.