I was trying to list category names. wp_list_categories()
returns a list of the categories but the problem is that it automatically wraps the names with links. I do not need the links.
It is possible to disable the links by JavaScript? But then I would have to fire some JS event.
I need to retrieve the category list without the automatic anchor tags, any idea?
This works well, with less code:
<?php
$category = get_the_category();
echo $category[0]->cat_name;
?>
You can achieve this using the wordpress function get_categories(), this should work :
PHP
<ul>
<?php
foreach (get_categories() as $category){
echo "<li>";
echo $category->name;
echo "</li>";
} ?>
</ul>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With