Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using custom taxonomies. I have multiple categories and each category has multiple children. I would like to display the categories in two columns on my homepage similar to linkcentre.com.

I tried using wp_list_categories but could not split its output into two columns.

I tried this solution but it only works when there are no subcategories.

Thanks

share|improve this question
    
I answered a similar question here. I think it will work for you. wordpress.stackexchange.com/questions/25433/… –  Rutwick Gangurde Nov 17 '11 at 9:31
    
actually it would work fine if there are no subcategories. In our case each category has multiple children so count($cats) will also include the number of child categories. –  Ankit Nov 17 '11 at 12:00

1 Answer 1

up vote 1 down vote accepted

You don't need any code changes to your PHP or html!

Assuming the following code was used:

<ul class="mypagelist">
    <?php wp_list_pages('sort_column=menu_order&title_li='); ?>
</ul>

Resulting in:

<ul class="mypagelist">
    <li>Page 1</li>
    <li>Page 2</li>
    <li>Page 3</li>
    <li>Page 4
        <ul>
            <li>Subpage 1</li>
        </ul>
    </li>
    <li>Page 5</li>
</ul>

Use CSS along the following lines:

.mypagelist { width:600px; /* or any other size */ }
.mypagelist li { float:left; width:290px; margin-right:10px /* width + margin = width of parent divided by 2 */ }
.mypagelist li ul { display: none; /* don't show subpages */ }

Finally, we need a clearing element at the end ( or on the container containing the page list call ). e.g. <div style="clear:left;"></div>, although I would avoid inline styling where possible.

The same can be done for any unordered list, categories, pages, nav menus, etc

share|improve this answer
    
interesting take on the problem.... I will try to implement it and see if it works for our case... –  Ankit Nov 17 '11 at 12:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.