Created
June 1, 2016 09:25
-
-
Save dededey/9ac8ac34d0696e5ce354f8678ab33132 to your computer and use it in GitHub Desktop.
get category links array hierarcal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$args = array( | |
'orderby' => 'name', | |
'order' => 'ASC', | |
'hide_empty' => '0', | |
'hierarchical' => 1, | |
); | |
$categories = get_categories($args); | |
// var_dump($categories); | |
foreach( $categories as $category ) { | |
if($category->parent==0){ | |
echo "<div id=\"chisiamo\"> | |
<h3>".$category->cat_name."</h3>"; | |
echo "<ul>"; | |
foreach ($categories as $cat) { | |
if($cat->parent==$category->term_id){ | |
echo "<li><a href=\"".get_category_link($cat->term_id)."\">".$cat->name."</a></li>"; | |
} | |
} | |
echo "</ul>"; | |
echo "</div>"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment