RSS and PHP - Using category name (2 posts)

  1. pokeey
    Posted 11 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.


  2. Kafkaesqui

    Posted 11 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):

    $categories = get_the_category();
    $catsnum = count($categories);
    $hits = 0;
    $sep = ', ';
    foreach ($categories as $category) {
    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


No tags yet.