在wordpress主題制作開發(fā)中經(jīng)常會需要在特定的頁面中調(diào)用出指定的文章或文章列表,,接下來就來教大家如何調(diào)用出wordpress文章列表。
調(diào)用網(wǎng)站最新文章:
<?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() ?></a></li> //這里可以寫成你自己需要的樣式<?php endwhile; ?>
調(diào)用隨機(jī)文章:
<?php query_posts('showposts=10&orderby=rand'); //showposts=10表示10篇while (have_posts()): the_post(); ?><li><a href="<?php the_permalink(); ?>" target="_blank"><?php the_title() ?></a></li> //這里可以寫成你自己需要的樣式<?php endwhile; ?>
調(diào)用某個分類下的最新文章:
<?php query_posts('showposts=10&cat=1'); //cat=1為調(diào)用ID為1的分類下文章while (have_posts()) : the_post(); ?><li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?>
排除某個分類下的文章:
<?php query_posts('showposts=10&cat=-1'); //cat=-1為排除ID為1的分類下文章while (have_posts()) : the_post(); ?><li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?>
以上就是文章列表的調(diào)用方法,,可以將例子中的代碼結(jié)合起來達(dá)到你需要的效果,。