Skip to content

Instantly share code, notes, and snippets.

@lvwzhen
Last active October 11, 2015 22:38
Show Gist options
  • Save lvwzhen/3930268 to your computer and use it in GitHub Desktop.
Save lvwzhen/3930268 to your computer and use it in GitHub Desktop.
wordpress 首页调用分类目录下的文章
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args=array(
'cat' => '', // 分类ID,单引号中填写具体ID,在你后台的分类目录中鼠标查找
'posts_per_page' => 5, // 显示篇数
'paged'=>$paged,
);
query_posts($args);
if (have_posts()) : while (have_posts()) : the_post();
?>
<div class="poss" id="post-<?php the_ID(); ?>" >
<h2><a href="<?php the_permalink() ?>"><?php the_title_attribute(); ?></a></h2>
<?php the_content("Read More..."); ?>
</div>
<?php endwhile; endif; wp_reset_query();?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment