当前位置: 首页 » 网站建设 » wordpress教程 » 正文

wordpress分类页面显示子分类文章列表

发布时间:2025-01-16 以下文章来源于网友投稿,内容仅供参考!

测速网在接受客户的wordpress仿站中项目中,需要在分类页面调用子分类的文章列表,类似的列表效果在很多cms程序中比较常见,但对于wordpress程序,可以使用下面的分类代码来完全功能的实现。

把以下代码调整后添加到主题的category.php文件:

area data-settings="dblclick" readonly ><?phpglobal $cat;$cats = get_categories(array('child_of' => $cat,'parent' => $cat,'hide_empty' => 0));$c = get_category($cat);if(empty($cats)){?><div ><?php if (have_posts()) : while (have_posts()) : the_post(); ?><div ><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 ><?php the_time('Y-m-d'); ?> | 标签: <?php the_tags('', ' , ', ''); ?></div></div><?php endwhile; ?><?php else: ?><div ><p>文章稍后更新</p></div><?php endif; ?></div><div ><span ><?php next_posts_link('&laquo; Older posts') ?></span><span ><?php previous_posts_link('Newer posts &raquo;') ?></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 ><div ><h2><a title="'.$the_cat->name.'" href="'.get_category_link($the_cat).'">'.$the_cat->name.'</a></h2></div> <ul >';foreach($posts as $post){echo '<li><span >'.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>';}}}?>area>16171819202122232425262728293031323334353637383940414243444546474849<?phpglobal $cat;$cats = get_categories(array('child_of' => $cat,'parent' => $cat,'hide_empty' => 0));$c = get_category($cat);if(empty($cats)){?><div ><?php if (have_posts()) : while (have_posts()) : the_post(); ?><div ><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 ><?php the_time('Y-m-d'); ?> | 标签: <?php the_tags('', ' , ', ''); ?></div></div><?php endwhile; ?><?php else: ?><div ><p>文章稍后更新</p></div><?php endif; ?></div><div ><span ><?php next_posts_link('&laquo; Older posts') ?></span><span ><?php previous_posts_link('Newer posts &raquo;') ?></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 ><div ><h2><a title="'.$the_cat->name.'" href="'.get_category_link($the_cat).'">'.$the_cat->name.'</a></h2></div><ul >';foreach($posts as $post){echo '<li><span >'.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>';}}}?>
  • • 开启wds是什么意思?无线路由器wds是怎么开启?

    开启wds是什么意思?WDS是英文Wireless Distribution System的简称,中文名称是:无线分布式系统。WDS功能就是一种帮助无线基站与

  • • 系统boot是什么意思?电脑出现boot manager怎么办?

    系统boot是什么意思1、开机后我们连续按启动热键,进入bios界面,我们就可以看到boot了。2、boot有启动的意思,在电脑中就是指电

  • • win10系统msconfig无法正常启动怎么办?win10系统msconfig怎么设置最

    msconfig打不开解决办法:1.先打开电脑开始菜单,在操作窗口输入regedit,打开注册表编辑器。然后将HKEY_LOCAL_MACHINE\SOFTWARE

  • • 金士顿u盘怎么写保护?金士顿U盘恢复出厂设置怎么操作?

    金士顿u盘怎么写保护?方法一:如果你的U盘如我简介中说的那样,有一个自带的物理写保护的小 开关 ,就观察一下是不是已经将开关

  • • 苹果AirPods Pro 2发布 搭载H2芯片降噪能力翻倍

    9月8日凌晨,苹果正式发布第二代主动降噪耳机AirPods Pro 2,搭载H2芯片,降噪能力翻倍,而且续航也飚至30小时。得益于全新的H2

  • biubiu加速器
    九游优盟游戏推广平台
    九游推广联盟
    digdig游戏入口
    4999小游戏大全
    九游游戏网
    站长素材
    植物大战僵尸杂交免费版
    站长之家
    测速网在线测网速
    354211邮编查询,354211邮政编码查询
    354209邮编查询,354209邮政编码查询
    353132邮编查询,353132邮政编码查询
    354215邮编查询,354215邮政编码查询
    353121邮编查询,353121邮政编码查询
    354213邮编查询,354213邮政编码查询
    353125邮编查询,353125邮政编码查询
    354201邮编查询,354201邮政编码查询
    353101邮编查询,353101邮政编码查询
    354200邮编查询,354200邮政编码查询