调用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; ?>
<?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 结束-->
转自:http://eelsee.blog.163.com/blog/static/180018332201162054424796/





发表回复