wordpress分类页调用所有子分类文章列表
wordpress 分类页调用当前分类所有子分类文章列表代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | <?php global $cat; $cats = get_categories(array( 'child_of' => $cat, 'parent' => $cat, 'hide_empty' => 0 )); $c = get_category($cat); if(empty($cats)){?> <div class="item"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="post"> <h2><a title="<?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <p><?php the_excerpt(); ?></p> <p><a href="<?php the_permalink(); ?>">全文阅读>></a></p> <div class="meta"><?php the_time('Y-m-d'); ?> | 标签: <?php the_tags('', ' , ', ''); ?></div> </div> <?php endwhile; ?> <?php else: ?> <div class="post"><p>文章稍后更新</p></div> <?php endif; ?> </div> <div class="navigation"> <span class="alignleft"><?php next_posts_link('« Older posts') ?></span> <span class="alignright"><?php previous_posts_link('Newer posts »') ?></span> </div> <?php}else{ foreach($cats as $the_cat){ $posts = get_posts(array( 'category' => $the_cat->cat_ID, 'numberposts' => 10, )); if(!empty($posts)){ echo ' <div class="item cat_item"> <div class="item_title"><h2><a title="'.$the_cat->name.'" href="'.get_category_link($the_cat).'">'.$the_cat->name.'</a></h2></div> <ul class="box_list">'; foreach($posts as $post){ echo '<li><span class="alignright">'.mysql2date('Y-m-d', $post->post_date).'</span> <a title="'.$post->post_title.'" href="'.get_permalink($post->ID).'">'.$post->post_title.'</a></li>'; } echo '</ul> </div>'; } }}?> |
WORDPRESS获取当前分类下所有子分类名称
1 2 3 4 5 6 7 8 9 10 11 12 | <?php $a=get_category_root_id($cat); $args=array( 'orderby' => 'id', 'hide_empty' => "0", 'child_of' => $a,//可以换为:'child_of' => '1', ); $categories=get_categories($args); foreach($categories as $category) { ?> <?php echo $category->name; ?> <?php }?> |
WORDPRESS获取当前分类下所有子分类链接
1 2 3 4 5 6 7 8 9 10 11 12 | <?php $a=get_category_root_id($cat); $args=array( 'orderby' => 'id', 'hide_empty' => "0", 'child_of' => $a,//可以换为:'child_of' => '1', ); $categories=get_categories($args); foreach($categories as $category) { ?> <?php echo get_category_link( $category->term_id ) ?> <?php }?> |
WORDPRESS获取当前分类下所有子分类文章列表
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | <ul> <?php $a=get_category_root_id($cat); $args=array( 'orderby' => 'id', 'hide_empty' => "0", 'child_of' => $a,//可以换为:'child_of' => '1', ); $categories=get_categories($args); foreach($categories as $category) { ?> <li> <a href="<?php echo get_category_link( $category->term_id ) ?>" title="<?php echo sprintf($category->name ) ?>" > <?php echo $category->name; ?> </a> <ul> <?php $c=$category->term_id; ?> <?php $display_categories = array($c); foreach ($display_categories as $category) { ?> <?php query_posts("showposts=8&cat=$category")?> <?php while (have_posts()) : the_post(); ?> <li> <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" target="_self"> <?php echo mb_strimwidth(strip_tags(apply_filters('the_title()', $post->post_title)), 0,30,""); ?> </a> </li> <?php endwhile; ?> <?php } wp_reset_query();?> </ul> </li> <?php }?> </ul> |
浅唱6(微信/QQ号:909912499),欢迎分享本文,转载请保留出处!部分内容来自网络,如有侵权请联系删除处理!
相关信息
本站提供代码修改,dedecms,WordPress仿站二次开发 / PHP网站建设以及SEO优化等网络营销推广等服务。
如有需要请加QQ: 909912499