21 June 2019

Display the all category in wordpress in a page

<?php
    $args = array(
      'orderby' => 'name',
      'hierarchical' => 1,
      'taxonomy' => 'category',
      'hide_empty' => 0,
      'parent' => 0,
    'exclude' =>1,
    );
    $categories = get_categories($args);

    foreach($categories as $category) {

      echo '<a href="' . get_category_link($category->cat_ID) . '" title="' . $category->name . '">' . $category->name . '</a><br>';
   echo '<a href="' . get_category_link($category->cat_ID) . '" title="' . $category->description . '">' . $category->description . '</a><br>';

      }
  ?>

OR

<?php wp_list_cats('optionall=0&depth=1&list=0&exclude=1&children=0&hide_empty=0'); ?>


OR


 <ul>
  <?php
  $i = "delay-1";
    $args = array(
      'orderby' => 'name',
  'order' => 'asc',
      'hierarchical' => 1,
      'taxonomy' => 'category',
      'hide_empty' => 0,
      'parent' => 0,
  'exclude' =>1,
  'number' =>6,
    );
    $categories = get_categories($args);

    foreach($categories as $category) {
?>
        <li  class="block animatable bounceInLeft <?php echo $i++ ?> ">
          <div class="product-category-content">
            <h3><a href="<?php echo get_category_link($category->cat_ID); ?>"><?php echo $category->name; ?></a></h3>
            <p><?php echo $category->description; ?></p>
          </div>
        </li>
<?php } ?>
      </ul>