Support » Themes and Templates » Category Name in -text- form

  • Resolved deeltje


    I’d like to display the category in -text- form so I can adjust the exact CSS for that particulary page.

    Right now I’m just using

    <?php the_category(', ') ?>

    It would be much better if i could

    <a href="<?php the_category(', ') ?>">Category Name</a>


    Can anybody help me with this?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The function can return more then one result..

    So you can’t place it inside the href.

    The comma is just the seperator.

    Take a look at what i suggested here.

    wp_list_categories(); is proberly better suited to what you want…

    <?php $my_query = new WP_Query('showposts=6');
    while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID; ?>
    <div id="contentslider_menu">
    <div class="contentslider_menubalk_streep">
    <div class="contentslider_menubalk">
    <a href="<?php the_permalink(); ?>" class="toc">
    <div class="knop_titel"><p class="wit"><?php the_title(); ?>
    <div class="knop_datum"><p class="wit"><?php the_title(); ?>
    <div class="knop_category"><p class="wit">Category
    <?php endwhile; ?>

    I’m using above code, and things like title etc. are working perfect. The problem is that withing this code I only need the -echo- -text- output, because everything is allready in a <a href=""></a> .

    I’ve tried your solution t31os_, but that still gives me a link-output.

    Isn’t there a way to just -echo- -text- the Category Description?

    Use the following in place of Category

    foreach((get_the_category()) as $category) {
        echo $category->cat_name . ' ';

    Reference Link:

    I like that, short, simple and functional… nice one.. 😉

    Minimalist code. 🙂

    Perfect, thanks! And for the category.php I used <?php single_cat_title() ?>, works like a charm! Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Category Name in -text- form’ is closed to new replies.