Created
October 6, 2014 04:17
-
-
Save fangcat/641a78f365f2986c21b1 to your computer and use it in GitHub Desktop.
分類圖示與產品頁
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 | |
global $cat; | |
$cats = get_categories(array( | |
'child_of' => $cat, | |
'parent' => $cat, | |
'hide_empty' => 0 | |
)); | |
$c = get_category($cat); | |
if(empty($cats)){ | |
?> | |
<?php if (have_posts() ) : while ( have_posts() ) : the_post(); ?> | |
<div class="post-list"> | |
<article> | |
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('medium'); ?></a> | |
<h6><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h6> | |
</article> | |
</div> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
<?php | |
}else{ | |
foreach($cats as $the_cat){ | |
$posts = get_posts(array( | |
'category' => $the_cat->cat_ID, | |
'numberposts' => 200, | |
)); | |
if(!empty($posts)){ | |
$my_icon = get_cat_icon('echo=false&cat='.$the_cat->cat_ID); | |
echo ' | |
<div class="post-list"> | |
<a title="'.$the_cat->name.'" href="'.get_category_link($the_cat).'">'.$my_icon.'</a> | |
<h6><a title="'.$the_cat->name.'" href="'.get_category_link($the_cat).'">'.$the_cat->name.' | |
</a></h6> | |
</div>'; | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment