Is Parent selected when Child Category is chosen? (9 posts)

  1. Lorelle
    Posted 11 years ago #

    In WordPress the:

    is filed under <?php the_category(', ') ?>

    lists the categories that your post is filed under. Now, if you choose only the child of a Parent, say Cat1 > Sub1, will it show only Sub1 or will it show Cat1, Sub1?

  2. Kafkaesqui

    Posted 11 years ago #

    Show "Cat1 > Sub1" where? Such a hierarchy is shown in the url when using custom permalinks, but if you mean the page title for that sub-category, no.

    Or are you asking something completely different?

  3. Lorelle
    Posted 11 years ago #

    In the "Filed Under" that comes with most of the templates. The "gray box" as so many call it where it says "Posted on blah date and filed under this and that categories and you can rss and pingback, etc."

    In the tag <?php the_category(', ') ?> does it include the parent or just the child if the parent is unchecked when the post is saved?

  4. Kafkaesqui

    Posted 11 years ago #

    Ah. The default is to link/display just the child, with no parent<>child relationship exhibited. To change this, see the info on the 'parent' parameter:


    (I know you know how to find it, but one never knows who is reading.)

    Little more expo on 'parent':

    single: Parent/Child - single link
    multiple: Parent/Child - link to each

  5. Lorelle
    Posted 11 years ago #

    Yes, but there is a feature:

    (string) How to display links that reside in child (sub) categories. Options are:

    * "multiple" - Display separate links to parent and child categories, exhibiting "parent/child" relationship.
    * "single" - Display link to child category only, with link text exhibiting "parent/child" relationship.

    So how do you use this? I would want the multiple.

    Different parameters use different methods, some with single quotes and commas, some with equals and ampersands...how would this work to put the multiple parameter in?

    I missed this on the first read through of the template tag.

  6. Lorelle
    Posted 11 years ago #

    Ah, I'm really slow tonight. It says:

    <?php the_category('separator', 'parents' ); ?>

    So I'm going to try:

    <?php the_category(', ', 'multiple') ?>

    and see what it gets me.

  7. Kafkaesqui

    Posted 11 years ago #

    <?php the_category(', ', 'multiple'); ?>
    <?php the_category(', ', multiple); ?>

    Both will work, though 'we' suggest using the quotes (just to keep in the habit for text strings).

  8. Lorelle
    Posted 11 years ago #

    Well, I tried it and this is what I got:

    Filed under Cat1, Cat2/Sub1, Cat3...

    I don't like the slash to denote the parent/child relationship. Wish there was a way to make that just part of the comma lines so it would list:

    Filed under Cat1, Cat2, Sub1, Cat3...

    Oh, we always ask so much...

    Thanks for your help on this. If I'd plugged at it long enough, I could have figured it out, but I so love being the questioner once in a while.

  9. Kafkaesqui

    Posted 11 years ago #

    I think the question was "why can't I modify all the WordPress features through simple parameters to my heart's delight?"

    And the answer is "because."

    Yes. Sadly, that _is_ the answer.

Topic Closed

This topic has been closed to new replies.

About this Topic