deeltje
Member
Posted 3 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>
everything.
Can anybody help me with this?
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.
http://wordpress.org/support/topic/255865?replies=5
wp_list_categories(); is proberly better suited to what you want...
kapiljain.in
Member
Posted 3 years ago #
deeltje
Member
Posted 3 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">
<ul><li>
<a href="<?php the_permalink(); ?>" class="toc">
<div class="knop_titel"><p class="wit"><?php the_title(); ?>
</div>
<div class="knop_datum"><p class="wit"><?php the_title(); ?>
</div>
<div class="knop_category"><p class="wit">Category
</div>
</a>
</li></ul>
</div></div></div>
<?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?
kapiljain.in
Member
Posted 3 years ago #
Use the following in place of Category
<?php
foreach((get_the_category()) as $category) {
echo $category->cat_name . ' ';
}
?>
Reference Link: http://wordpress.org/support/topic/171029?replies=5
I like that, short, simple and functional... nice one.. ;)
Minimalist code. :)
deeltje
Member
Posted 3 years ago #
@kapiljain.in
Perfect, thanks! And for the category.php I used <?php single_cat_title() ?>, works like a charm! Thanks!