
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来获取这个标签下的所有文章
标签: cat, showposts, 文章调用, 随机文章, 随机读取
上面是“wordpress当前分类下随机文章调用代码”的全面内容,想了解更多关于 wordpress 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_2413.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

如何利用sql语句插入数据
MathGPT:好未来自主研发的国内首款数学领域专用大模型
欧路翻译:提供鼠标划词搜索、逐段对照翻译、PDF文献翻译功能
什么样的文章容易被百度收录?
DeepSeek Coder:一款DeepSeek推出的专注于代码生成与辅助开发的AI工具