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


调用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')


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM