加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > CMS系统 > wordpress > 正文

wordpress get_posts函数的使用方法 禁止输出指定类别的文章

发布时间:2020-12-14 14:47:47 所属栏目:wordpress 来源:网络整理
导读:使用wordpress禁止输出指定类别的文章可以给get_posts()函数传个数组参数,如下:div class="msgborder" id="phpcode3"div class="widget" id="diary1" 随机呈现 ?php $args=array( 'numberposts'=16, 'category'='-9,-12', 'orderby'='rand' ); $rand_posts

使用wordpress禁止输出指定类别的文章可以给get_posts()函数传个数组参数,如下:<div class="msgborder" id="phpcode3"><div class="widget" id="diary1">

随机呈现

    <?php $args=array( 'numberposts'=>16, 'category'=>'-9,-12', 'orderby'=>'rand' ); $rand_posts = get_posts($args); foreach( $rand_posts as $post ) : ?>
  • <a href="<?php the_permalink(); ?>"><?php the_title(); ?>
  • <?php endforeach; ?>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读