前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >wordpress 使用 WP_Query 实现最新n条文章

wordpress 使用 WP_Query 实现最新n条文章

作者头像
切图仔
发布2022-09-14 15:40:01
1560
发布2022-09-14 15:40:01
举报
文章被收录于专栏:生如夏花绚烂
代码语言:javascript
复制
<?php 
                       $post_query = new WP_Query('showposts=10');
                       while($post_query->have_posts()) : $post_query->the_post();
                       $do_not_duplicate  = $post_ID;?>
                    <li class="media">
                        <div class='media-header'>
                             <img src="static/picture/u=3860383438,3596170004&amp;fm=26&amp;gp=0.jpg"   height='150' width='250' class="mr-3 d-none d-sm-block" alt="...">
                            <div class='tags' style='width:97%'>
                                <span><span class='text-warning'>&nbsp;</span>前端</span>
                                <time><span class='text-primary'> </span><?php the_time('Y-m-d H:i:s')?></time>
                                <span><span class='text-secondary'> </span>浏览(0)</span>
                                <span><span class='text-info'>&nbsp;</span><?php the_author()?></span>
                                <span class='float-right '><a href="<?php the_permalink()?>" class='text-success'>++阅读原文</a></span>
                            </div>
                        </div>
                        <div class="media-body">
                          <h5 class="mt-0 mb-1 h5"><?php the_title();?></h5>
                            <?php the_content();?>
                        </div>
                    </li>
                    <?php endwhile;?>

WP_Query更多配置参考 https://www.boke8.net/wordpress-wp_query.html

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

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

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

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

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