Skip to content

Instantly share code, notes, and snippets.

@fangcat
Created October 6, 2014 04:17
Show Gist options
  • Save fangcat/641a78f365f2986c21b1 to your computer and use it in GitHub Desktop.
Save fangcat/641a78f365f2986c21b1 to your computer and use it in GitHub Desktop.
分類圖示與產品頁
<?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