WordPress.org

Support

Support » How-To and Troubleshooting » RSS and PHP – Using category name

RSS and PHP – Using category name

  • 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

Viewing 1 replies (of 1 total)
  • 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;
    } ?>

Viewing 1 replies (of 1 total)
  • The topic ‘RSS and PHP – Using category name’ is closed to new replies.