Quantcast
Viewing all articles
Browse latest Browse all 10

How to display all Categories in Multiple Columns in your WordPress site

Some time ago I want to display all categories (all the parent and child) of my site in the footer in the multiple columns. All the codes on the net were useless for me because some code display categories list in the definite row or some were showing in the hierarchy. Then I read the documentation on wordpress and found a very interesting function wp_list_categories that can be used for displaying or retrieve the html list of the categories.


Image may be NSFW.
Clik here to view.

You can extend its capabilities according to your requirement by passing some arguments.
Here I am describing you how you can show all categories without any hierarchy
You can pass ‘hierarchical=0′ or ‘hierarchical=1′, if you don’t want to show the categories in hierarchy then you can use ‘hierarchical=0′ otherwise use ‘hierarchical=1′.

  1. <div id="footCatories">
  2.  <?php wp_list_categories('hierarchical=0'); ?>
  3. </div>

Or if you want to show categories order by their name then you can use :

  1. <div id="footCatories">
  2.  <?php wp_list_categories('orderby=name@hierarchical=0'); ?>
  3. </div>

I have also create CSS for the list of the categories, you can use this:

  1. #footCatories {
  2.     height: auto !important;
  3.     min-height: 100px;
  4.     min-width: 1024px;
  5.     overflow: hidden;
  6.     padding: 10px 0;
  7.     width: 100%;
  8. }
  9. #footCatories ul li {
  10.      display: block;
  11.     float: left;
  12.     line-height: 16px;
  13.     padding-right: 5px;
  14.     width: 160px;
  15. }
  16. #footCatories ul {  
  17. float: left;
  18.     list-style: none outside none;
  19.     margin: 0;
  20.     padding: 0;
  21.     width: 100%;
  22. }

Viewing all articles
Browse latest Browse all 10

Trending Articles