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

1087 ℃

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://m.ipkd.cn/webs_2413.html

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

Trae:新一代免费的AI编程工具
wordpress如何利用wp_delete_comment删除评论
JS获取url参数code,根据code判断改变当前页面颜色
帝国cms列表页模板动态获取文章内容点击数
新站SEO优化需要注意哪些点?
详解Dedecms 5.5 实现自定义标题处理(附采集规则