• Resolved malcolmcoles

    (@malcolmcoles)


    I’m using the_category to show the parent category and child category of individual posts (which are assigned to one child category only).

    I’m doing so on the post page (I know it says to do so within the loop here, but it seems to work outside the loop).

    Anyway, this returns something like: Parent,Child with both parent and child already the correct links. This is 95% of what I need.

    However, I don’t like the way there is no space before or after the comma – and ideally, I want to replace the comma with something to indicate the parent/child relationship, like a ‘>’.

    So I’ve tried this:

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

    But it doesn’t work.

    I’ve also tried doing something similar having done
    $variable = the_category(' , ', 'multiple'))
    and then doing the str_replace on %variable, but that didn’t work either.

    Any ideas …? Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to replace the comma in the_category output’ is closed to new replies.