Skip to content

Instantly share code, notes, and snippets.

@LinzardMac
Created January 20, 2013 22:03
Show Gist options
  • Save LinzardMac/4582105 to your computer and use it in GitHub Desktop.
Save LinzardMac/4582105 to your computer and use it in GitHub Desktop.
<nav id="subPageNav">
<?php
// Grab the categories - top level only (depth=1)
$get_cats = wp_list_categories( 'echo=0&title_li=&depth=1' );
// Split into array items
$cat_array = explode('</li>',$get_cats);
// Amount of categories (count of items in array)
$results_total = count($cat_array);
// How many categories to show per list (round up total divided by 5)
$cats_per_list = ceil($results_total / 5);
// Counter number for tagging onto each list
$list_number = 1;
// Set the category result counter to zero
$result_number = 0;
?>
<ul id="filters">
<li><a href="#" data-filter="*">Show All</a></li>
<?php
$args=array(
'orderby' => 'name',
'order' => 'ASC'
);
$categories=get_categories($args);
foreach($categories as $category) {
?>
<li><a href="#" data-filter=".category-<?php echo $category->slug; ?>"><?php echo $category->name; ?></a></li>
<?php } ?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment