Created
July 15, 2014 18:39
-
-
Save drrobotnik/8f2c5a75f19ef7021279 to your computer and use it in GitHub Desktop.
category page
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 get_header(); ?> | |
<div class="sub-section"><?php | |
get_template_part( 'layout', 'gallery' ); | |
get_template_part( 'layout', 'sub-menu' ); | |
?></div> | |
<div id="primary" class="content-area site-archives"> | |
<div id="content" class="site-content" role="main"> | |
<h3>Categories</h3> | |
<ul class="arc-list clearfix" id="categories"> | |
<?php $categories = get_categories( array('hierarchical'=>0) ); | |
foreach ($categories as $category) { | |
$option = '<li><a href="'.get_category_link( $category ).'">'; | |
$option .= $category->cat_name; | |
$option .= ' ('.$category->category_count.')'; | |
$option .= '</a></li>'; | |
echo $option; | |
} | |
?> | |
</ul> | |
<h3>Tags</h3> | |
<?php $list = ''; | |
$tags = get_terms( 'post_tag' ); | |
$groups = array(); | |
if( $tags && is_array( $tags ) ) { | |
foreach( $tags as $tag ) { | |
$first_letter = strtoupper( $tag->name[0] ); | |
$groups[ $first_letter ][] = $tag; | |
} | |
if( !empty( $groups ) ) { | |
foreach( $groups as $letter => $tags ) { | |
$list .= "\n\t" . '<h4>' . apply_filters( 'the_title', $letter ) . '</h4>'; | |
$list .= "\n\t" . '<ul class="arc-list">'; | |
foreach( $tags as $tag ) { | |
$url = esc_attr( get_tag_link( $tag->term_id ) ); | |
$count = intval( $tag->count ); | |
$name = apply_filters( 'the_title', $tag->name ); | |
$list .= "\n\t\t" . '<li><a href="' . $url . '">' . $name . '</a> (' . $count . ')</li>'; | |
} | |
$list .= "\n\t" . '</ul>'; | |
} | |
} | |
}else $list .= "\n\t" . '<p>Sorry, but no tags were found</p>'; | |
$tags = get_tags(); | |
$html = ''; | |
foreach ($tags as $tag){ | |
$tag_link = get_tag_link($tag->term_id); | |
$html .= "<li><a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>"; | |
$html .= "{$tag->name}</a></li>"; | |
} | |
$html .= ''; | |
echo $list; ?> | |
</div> | |
</div> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment