WordPress.org

Ready to get started?Download WordPress

Forums

RSS and PHP - Using category name (2 posts)

  1. pokeey
    Member
    Posted 9 years ago #

    Greatings all,

    I am in yet another quandry. :(

    How do I go about getting the Category name in the <channel>/<title>

    So I would have <title>Brainfart central blog- Cat title here</title>

    I'v tried using <?php the_category_rss() ?> but that didn't cut the mustard because it puts <category> in there also. I just want the category name. Is this possible using php?

    Once again any help would be much appreciated.

    Chris

  2. Kafkaesqui

    Posted 9 years ago #

    This is a bit of code, but it duplicates the_category_rss() output without the tags (and adds a comma to separate multiple categories):

    <?php
    $categories = get_the_category();
    $catsnum = count($categories);
    $hits = 0;
    $sep = ', ';
    foreach ($categories as $category) {
    $hits++;
    echo convert_chars($category->cat_name);
    if($hits == $catsnum)
    $sep = '';
    echo $sep;
    } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.