Display category list without link wordpress

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.

Read More

I need to retrieve the category list without the automatic anchor tags, any idea?

Related posts

Leave a Reply

3 comments

  1. 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 with implode().

    For example:

    echo implode( ', ', wp_list_pluck( get_categories(), 'name' ) );