Created
May 10, 2013 07:28
-
-
Save psdtohtml5/5552934 to your computer and use it in GitHub Desktop.
WordPress : Getting All Categories
This file contains hidden or 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( | |
'type' => 'post', | |
'child_of' => 0, | |
'parent' => '', | |
'orderby' => 'name', | |
'order' => 'ASC', | |
'hide_empty' => 1, | |
'hierarchical' => 1, | |
'exclude' => '', | |
'include' => '', | |
'number' => '', | |
'taxonomy' => 'category', | |
'pad_counts' => false | |
); | |
//Getting all Categories | |
$categories = get_categories( $args ); | |
foreach ($categories as $category) { | |
$separator = ' '; | |
$output = ''; | |
$output .= ' | |
<a href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '"> | |
<img src="'.$category->description.'"></a>'.$separator;//using category description as in image url | |
echo trim($output); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment