wordpress建站中如何在文章页面获取当前分类下最新的10篇文章,下面web建站小编给大家简单介绍一下!
具体语法如下:
<?php
$categories = get_the_category();
$category_ids = array();
foreach( $categories as $category ) {
$category_ids[] = $category->term_id;
}
$args = array(
'post_type' => 'post',
'posts_per_page' => 10,
'post__not_in' => array( get_the_ID() ),
'category__in' => $category_ids,
'orderby' => 'date',
'order' => 'DESC'
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
echo '<h3>最新文章</h3>';
echo '<ul>';
while ( $query->have_posts() ) {
$query->the_post();
echo '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
}
echo '</ul>';
}
wp_reset_postdata();
?>
wordpress建站如何快速提交和优化您的网站(IndexNow插件)?
上面是“wordpress文章页面获取当前分类下最新的10篇文章”的全面内容,想了解更多关于 wordpress 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_4927.html
workflows工作流
1个可爱的白色短发女孩
一辆老式灵车在黑暗中从雾中出现ComfyUI工作流
乒乓卡通3d人物
一只可爱的飞鸟ComfyUI工作流
一只在星系中漂浮宇宙生物ComfyUI工作流
一张科幻照片,火星车在沙漠里ComfyUI工作流
图生图工作流:藏族姑娘ComfyUI工作流
一座古老的石阶,旁边有一棵树
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

javascript如何利用draggable实现一个拖拽效果
利用js+css3做一个小鱼游泳特效
css3结合svg做一个动态广告
纯html+css做一个3d统计效果
3D彩色卡片
jquery做一个漂亮挂墙动态时钟
利用js做一个炫酷音乐背景效果
css3搭积木叠加图形










