1

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

2
  • I answered a similar question here. I think it will work for you. wordpress.stackexchange.com/questions/25433/… Commented Nov 17, 2011 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
    Commented Nov 17, 2011 at 12:00

1 Answer 1

1

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

1
  • interesting take on the problem.... I will try to implement it and see if it works for our case...
    – Ankit
    Commented Nov 17, 2011 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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