[resolved] Category Name in -text- form (7 posts)

  1. deeltje
    Posted 7 years ago #

    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?

  2. Mark / t31os

    Posted 7 years ago #

    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...

  3. kapiljain.in
    Posted 7 years ago #

  4. deeltje
    Posted 7 years ago #

    <?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?

  5. kapiljain.in
    Posted 7 years ago #

    Use the following in place of Category

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

    Reference Link: http://wordpress.org/support/topic/171029?replies=5

  6. Mark / t31os

    Posted 7 years ago #

    I like that, short, simple and functional... nice one.. ;)

    Minimalist code. :)

  7. deeltje
    Posted 7 years ago #


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

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.