免费《新手做网站视频教程》,在线观看,如果你想从零开始自己做网站,点击开始吧!

WordPress 内容页面(single页)调用文章所属当前分类下的所有文章列表

  1. 首页
  2. »
  3. 图文教程
  4. »
  5. WordPress建站教程
  6. »
  7. WordPress 内容页面(single页)调用文章所属当前分类下的所有文章列表

文章目录

<?php
$singleurl = get_permalink($post_id);
$cats = wp_get_post_categories($post->ID);
if ($cats) {
    $args = array(
        'category__in'      => array( $cats[0] ),
        'showposts'         => 50,
        'caller_get_posts'  => 1,
        'order'             =>  'asc'
    );
    query_posts($args);
    if (have_posts()) :
        while (have_posts()) : the_post(); update_post_caches($posts); ?>
            <li>
                <a href="<?php the_permalink();?>"><?php the_title(); ?></a>
            </li>
        <?php endwhile; else : ?>
        <li> 暂无文章</li>
    <?php endif; wp_reset_query(); } ?>

推荐阅读

联系我