首页 > 其他 > 详细

WordPress主题开发:按分类调用文章

时间:2018-07-06 21:53:38      阅读:121      评论:0      收藏:0      [点我收藏+]

调用catid为2的分类下的文章,就是后台分类链接的tag_ID

<?php
$cat_query = new WP_Query(array(
    ‘cat‘ => ‘2‘
        ));
?>
<div id="sitebar">
    <ul class="nav nav-pills nav-stacked nav-og">
        <?php
        if ($cat_query->have_posts()) : while ($cat_query->have_posts()) : $cat_query->the_post();
                ?>
                <li><a href=“<?php the_permalink() ?>” target=“_blank” title=“<?php the_title(); ?>”><?php the_title(); ?></a></li>
            <?php endwhile; ?>
        <?php endif; ?>
    </ul>
</div>   

 获取当前分类id

get_query_var(‘cat‘)

WordPress主题开发:按分类调用文章

原文:https://www.cnblogs.com/tinyphp/p/6390285.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!