List all categories in wordpress

List all categories in wordpress

Free source code with WordPress for listing all categories and the responsive interface.

We use PHP code, have a beautiful style, using the bootstrap and please check the code like below.

<?php
$args = array(
  'orderby' => 'name',
  'parent' => 0,
'order' => 'ASC'
  );
$categories = get_categories( $args );?>
<div class="row">
<?php foreach ( $categories as $category ) { ?>
<div class="col-md-3 col-6 mb-3">
<a href="<?php echo get_category_link( $category->term_id )?>">
<div class="card">
<div class="card-body">
<?php 
echo '<div class="card-title">'.$category->name. '</div>' ;
echo '<div class="card-description">'. $category->description . '</div>';
echo '<div class="bgchildren text-center"><i class="fa fa-sticky-note" aria-hidden="true"></i> '. $category->count . ' posts</div>';
?>
</div>
</div>
</a>
</div>
<?php }?>
.bgchildren{
background: lightblue;
}

Share this Article !

You may like this