WordPress.org

Ready to get started?Download WordPress

Forums

To list categories in the <title> (separator) (9 posts)

  1. newboxters
    Member
    Posted 5 years ago #

    the_category view correctly, but with link:
    Parent Category > Children Category

    get_category_parents view without links, but with > after the last element:
    Parent Category > Children Category >

    As to show the the_category but without the link or to show get_category_parents but without the eparator after the last element?

    Thank you.

  2. newboxters
    Member
    Posted 5 years ago #

    I wonder if someone know which file I can edit this function (get_category_parents) and not show the separator after the last element?

  3. newboxters
    Member
    Posted 5 years ago #

    No is possible??

  4. razorguy
    Member
    Posted 5 years ago #

    <a href="<?php echo get_option('home'); ?>">Home</a>&nbsp;&rsaquo;&nbsp;&nbsp;<?php the_category('&nbsp;&rsaquo;&nbsp;&nbsp;', 'multiple' ); ?>&nbsp;&rsaquo;&nbsp;&nbsp;<?php the_title(); ?>

    That should work....

  5. razorguy
    Member
    Posted 5 years ago #

    tried and works perfectly!

  6. newboxters
    Member
    Posted 5 years ago #

    razorguy, that works, but he also generates the link. I needed that it separated in that way, but without the link.

    "As to show the the_category but without the link or to show get_category_parents but without the separator after the last element?"

  7. gszhl
    Member
    Posted 4 years ago #

    <?php
    foreach((get_the_category()) as $category) {
    echo $category->cat_name . ' ';
    }
    ?>

  8. newboxters
    Member
    Posted 4 years ago #

    gszhl

    <?php
    foreach((get_the_category()) as $category) {
    echo $category->cat_name . ' ';
    }
    ?>

    But this will don't show any separator?
    I just don't wanted show the last separator. Is it possible?
    Thank you.

  9. ty
    Member
    Posted 4 years ago #

    building from gszhl's and razorguy's posts:

    <?php
    $my_title_cats = '';
    foreach (get_the_category() as $category)
       $my_title_cats .= $category->cat_name . '&nbsp;&rsaquo;&nbsp;&nbsp;';
    echo substr($my_title_cats, 0, -26);
    ?>

    is one way that might work for you.
    peace~

Topic Closed

This topic has been closed to new replies.

About this Topic