欢迎来到站长天空!

WordPress

当前位置: 主页 > CMS教程 > WordPress

wordpress 在文章内容页获取相关文章,本文章所在分类的其它文章的方法

时间:2025-10-17 15:24:36|栏目:WordPress|点击:

可排除自身.

<?php 
if ( is_single() ) : 
global $post; 
$categories = get_the_category(); 
foreach ($categories as $category) : 
    ?> 
    
        <?php 
        $posts = get_posts('numberposts=5&category='. $category->term_id.'&exclude='.get_the_ID()); 
        foreach($posts as $post) : 
        ?> 
            <li> 
            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> 
            </li> 
        <?php endforeach; ?> 
     
<?php 
endforeach; endif ; ?>


上一篇:wordpress 特色图片去掉width宽度 直接调用src 缩略图自适应响应式

栏    目:WordPress

下一篇:WordPress 去掉网址中的index.php

本文标题:wordpress 在文章内容页获取相关文章,本文章所在分类的其它文章的方法

本文地址:https://zz.feitang.co/CMSjiaocheng/25005.html

广告投放 | 联系我们 | 版权申明

申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:257218569 | 邮箱:257218569@qq.com

Copyright © 2018-2025 站长天空 版权所有 Powered by EyouCms冀ICP备14023439号