MD. Atiqur Rahman MD. Atiqur Rahman - 6 months ago 10
PHP Question

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 automatics links. I do not need the links.

It is possible to disable the links by JavaScript but I have to do some event firing with JS .

So , I need to retrieve the category list without the automatic anchor tags.

Any idea ?

Answer

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