web建站教程
  1. 首页
  2. vuejs
  3. js
  4. 好玩
  5. seo教程
  6. 前端知识
  7. 百度echarts
  8. 更多
    php入门
    nodejs
    mockjs
    reactjs
    mysql
    wordpress
    织梦cms
    帝国cms
    git教程
    IT知识
    模板大全
    休息站

wordpress当前分类下随机文章调用代码

514 ℃
     

wordpress建站如何利用代码调用随机当前分类下文章?下面web建站小编给大家介绍一下同分类随机文章的调用方法!

代码如下:

<?php
  $cat = get_the_category();
  foreach($cat as $key=>$category){
  $catid = $category->term_id;}
  $args = array('orderby' => 'rand','showposts' => 10,'cat' => $catid ); 
  $query_posts = new WP_Query();
  $query_posts->query($args);
  while ($query_posts->have_posts()) : $query_posts->the_post();?>
  
  <li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
  
  <?php endwhile;?>
  <?php wp_reset_query(); ?>

wordpress如何获取网站的最新文章、热门文章、随机文章?

wordpress利用TAG标签的ID来获取这个标签下的所有文章

wordpress建站利用orderby调用全站随机文章

wordpress调用全站热门文章(代码介绍)

wordpress调用当前分类下所有文章(代码介绍)

标签: cat, showposts, 文章调用, 随机文章, 随机读取

上面是“wordpress当前分类下随机文章调用代码”的全面内容,想了解更多关于 wordpress 内容,请继续关注web建站教程。

当前网址:https://ipkd.cn/webs_2413.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

当前位置: 网站首页 > wordpress
本文共计458个字,预计阅读时长4分钟
生活小工具,收录了80多款小工具
上一篇: 推荐一个免费、无版权的古典音乐下载的网站——Musopen
下一篇: 推荐一款免费在线图片处理工具——佐糖图片平台
x 打工人ai神器