前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Wordpress显示文章分类及分类链接

Wordpress显示文章分类及分类链接

作者头像
切图仔
发布2022-09-14 16:13:13
4910
发布2022-09-14 16:13:13
举报
文章被收录于专栏:生如夏花绚烂
代码语言:javascript
复制
<ul class="unorderList blogpage">
    <?php
    $args = array(
            'post_type'=>'post'
    );
    
    $query = new WP_Query($args);
    ?>

<?php if($query->have_posts()): ?>
    <?php while($query->have_posts()):$query->the_post();?>
    <li>
        <div class="blogImg">
            <?php the_post_thumbnail()?>
            <div class="blog_date"><?php the_time('M,d,Y')?></div>
        </div>
        <div class="blog_sec">
            <h3><a href="<?php the_permalink();?>"><?php the_title();?></a></h3>
            <span style="overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-line-clamp:2;-webkit-box-orient: vertical;"><?php the_excerpt();?></span>
            <div class="readmore">
                <!--  文章分类  -->
                <?php
                $the_post_category = get_the_category($post->id);
                foreach ($the_post_category as $category){
                    echo "<a href=".get_category_link($category->term_id).">".$category->cat_name."</a>";
                }?>

            </div>
        </div>
    </li>
<?php endwhile; endif; wp_reset_postdata();?>


</ul>
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020-10-20 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档