调用wordpress指定分类文章2种方法

调用wordpress指定分类文章第一种方法

<?php $posts = get_posts( "category=4&numberposts=10" ); ?>

<?php if( $posts ) : ?>

<ul><?php foreach( $posts as $post ) : setup_postdata( $post ); ?>

<li>

<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>

</li>

<?php endforeach; ?>

</ul>

<?php endif; ?>


调用wordpress指定分类文章第二种方法
<h2> <?php   wp_list_categories ( ' include=11&title_li=&style=none ' ) ?> </h2>  //输出 ID 为11的分类的标题

<?php   echo   category_description ( 11 ) ?>   //输出 ID 为11的分类的描述

<?php   query_posts ( ' showposts=5&cat=11 ' ) ?>   //query_posts 给 The Loop 限定的条件是:显示5篇日志和分类 ID 为11

<?php   while   ( have_posts ())  :  the_post () ?>   //The Loop 开始

<li><a href="
<?php   the_permalink ()   ?> " rel="bookmark" class="title"> <?php   the_title () ?> </a></li>  //用列表的方式输出带有链接的文章标题

<?php   endwhile ?>   //The Loop 结束

你可能感兴趣的:(调用wordpress指定分类文章2种方法)