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:
You can achieve this using the wordpress function get_categories(),
this should work :
PHP
You want to display a list of all existing categories but don’t like how
wp_list_categories()
formats the result. Try to use get_categories() instead, it just retrieves a list of category objects.You can combine it with wp_list_pluck(), which plucks a certain field out of each object (here the
name
key). You’ll get an array containing only this key, and you’ll be able to display your list withimplode()
.For example: