Wordpress特定文章列表的調用代碼

調用網站最新文章:

<?php
query_posts('showposts=10&orderby=new'); //showposts=10表示10篇
while(have_posts()): the_post();
?>
//這裏可以寫成你自己需要的樣式
<li><a href="<?php the_permalink(); ?>" target="_blank"><?php the_title();?> <?php the_time('Y-m-d'); ?></a></li>
<?php endwhile; ?>

調用隨機文章:

query_posts('showposts=10&orderby=rand');

調用某個分類下的最新文章:

query_posts('showposts=10&cat=1'); //cat=1爲調用ID爲1的分類下文章

排除某個分類下的文章:

query_posts('showposts=10&cat=-1'); //cat=-1爲排除ID爲1的分類下文章
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章