Created
June 28, 2015 04:45
-
-
Save ahmedmusawir/48b79a661ebb3bab7cc6 to your computer and use it in GitHub Desktop.
WP Get Category
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 | |
| $categories = get_the_category(); | |
| $separator = ' '; | |
| $output = ''; | |
| if($categories){ | |
| foreach($categories as $category) { | |
| $output .= '<a href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.'</a>'.$separator; | |
| } | |
| echo trim($output, $separator); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment