• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Nile Flores Media

Helping You Rock Out Your Website Like A Rockstar

  • Home
  • About
  • Blog
  • Portfolio
  • Hire Me
  • Resources
  • Contact
  • Blogging
  • WordPress
  • Social Media
  • SEO
  • Web Design
  • News
  • Podcast
You are here: Home » WordPress » How To Display Two Columns For Categories In WordPress

How To Display Two Columns For Categories In WordPress

By Nile Flores 16 Comments


Displaying two columns for categories in your WordPress is not too hard. Just takes a little php, html, and css. You can put this in your posts, pages, or sidebar.

We are taking the usual category code for WordPress.

<?php wp_list_categories(); ?>

and replacing it with the following code. This php splits up each category and into columns, much like splitting odds and evens. This code would go in your template where you want it displayed.

<?php
$cats = explode("<br />",wp_list_categories('title_li=&echo=0&depth=1&style=none'));
$cat_n = count($cats) - 1;
for ($i=0;$i< $cat_n;$i++):
if ($i<$cat_n/2):
$cat_left = $cat_left.'<li>'.$cats[$i].'';
elseif ($i>=$cat_n/2):
$cat_right = $cat_right.'<li>'.$cats[$i].'</li>';
endif;
endfor;
?>

After you have put the above code you are ready to add your HTML right after it. Remember you need to make sure to remember your css class definition, because you will be adding it to your theme’s stylesheet. Remember you can use your own definitions, but remember to make sure you are not already using them for another part of your theme.

<ul class="alignleft">
<?php echo $cat_left;?>
</ul>
<ul class="alignright">
<?php echo $cat_right;?>
</ul>

Now that you have the php and html done, you need to add your css. In the case of this tutorial, I have used alignleft and alignright for the classes.

.alignleft {
float: left;
}
.alignright {
float: right;
}

Of course, if you want to play with the css and do other things, by all means go ahead.


Filed Under: WordPress Tagged With: wordpress categories, wordpress tricks

About Nile Flores

Nile is a 43-year old female from the greater St. Louis (Southern Illinois side) area. Nile is a mother of 1 son. She is also a web designer and developer, a graphic designer, and a public speaker, who exclusively designs and develops using WordPress. She also blogs at GoDaddy's Blog, Verpex Hosting's blog and her very personal sites, Pixelled and Nail Polish Happy.




Related posts:

No related posts.

Reader Interactions

Comments

  1. Ryan says

    February 2, 2012 at 9:06 pm

    WordPress is very useful for beginners in website design. Thanks for the useful coding information.

    Reply
  2. vishvast says

    February 3, 2012 at 12:29 am

    hiii
    nile
    i was really in search for that hw i will dispaly two colums in categories so i got it here thnx for the complete codes and script very helpful

    Reply
  3. Abed Saragih says

    February 3, 2012 at 2:01 am

    Thanks for the info you’ve shared

    success is always
    Abed Saragih Blog

    Reply
  4. Amrik says

    February 3, 2012 at 8:44 am

    Hi Nile.. Thanks for sharing this tutorial. It is really helpful for me. I will use it for my clients websites.Cheers.

    Reply
  5. marquita herald says

    February 3, 2012 at 9:56 am

    I always appreciate the useful information you provide – and especially that it’s not just the same old stuff. Thanks!

    Reply
  6. Chris says

    February 3, 2012 at 4:55 pm

    Learn something new every day! It’s always beneficial to learn new ways to customize my wordpress blog. Not only will i use this on my site, i’m going to recommend it to friends!

    Reply
  7. Matthew London says

    February 4, 2012 at 7:07 am

    Whilst on the subject of two columns, is there a way of splitting WordPress content into two columns?

    Reply
  8. matt says

    February 4, 2012 at 8:00 pm

    Thanks, it’s very easy to understand instruction.

    Nile, can you also create a post on how to change background color. I would like to tweak the background of coraline theme I am currently using. Thanks…

    Reply
  9. Kajal Agarwal says

    February 6, 2012 at 6:50 am

    I don’t have any idea bout coding..!
    But i just follow the copy and paste technique!!!

    Reply
  10. Matthew London says

    February 7, 2012 at 4:58 pm

    I answered my own question on how to split content into two columns. There is a plugin available WP Post Columns. It does it nicely for me.

    Reply
  11. Anonymous says

    February 8, 2012 at 9:12 am

    Thank you so much for this post.I found lots of interesting information here. And thanks for sharing it’s really wonderful and useful =)))

    Reply
  12. Bobby says

    February 8, 2012 at 6:31 pm

    Thanks for posting this tutorial. I posted something similar to this on my blog. This tutorial is easy to follow.

    Reply
  13. japh says

    February 10, 2012 at 8:36 am

    thanks for this tutorial. very easy to follow, it’s very helpful. will share this to my wordpress buddies

    Reply
  14. Arjun Rai says

    March 7, 2012 at 4:01 am

    i have multiple wordpress sites and really these types of tips help to every wordpess owner, those are new and even who are some experience holder.

    Reply
  15. jobin says

    March 13, 2012 at 4:31 am

    Thank you for sharing this it is very useful to me…..very easy to follows…..

    http://www.findghar.com

    Reply
  16. akasharora says

    May 18, 2012 at 3:15 am

    Thank You very much Nile for writing such a great tutorial. Well Would you tell me How I can show Categories in 4 or 5 columns. Actually I want to show them in the footer of my blog.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Follow Me On:

  • Facebook
  • Instagram
  • LinkedIn
  • Twitter
  • YouTube

Get The Latest WordPress & Blogging Tips

Sign up for my newsletter, and also get my free ebook on 10 Reasons Why Your Website Isn't Converting, and How to Fix it!




Try to be More Positive on Social Media

Note: You can click on image and view the video in a larger lightbox window.

Footer

The Blog

Lots of free information, tutorials, and more to help you bring your best foot forward with your website.

  • Blogging
  • WordPress
  • Social Media
  • SEO
  • Web Design

Get The Latest WordPress & Blogging Tips

Sign up for my newsletter, and also get my free ebook on 10 Reasons Why Your Website Isn't Converting, and How to Fix it!

Copyright © 2025 · · WordPress