方法一、query_posts()函數(shù)
<?
query_posts('showposts=6&cat=10');
while (have_posts()) : the_post();
the_permalink();
the_title();
endwhile;
?>
上面代碼的意思是 讀取6篇文章,排除分類ID為10里面的文章
方法二、wp_get_archvies函數(shù)
語法結(jié)構:
<? wp_get_archives(‘type=postbypost&limit=20&format=custom’); ?>
type=postbypost:按最新文章排列
limit:限制文章數(shù)量最新20篇
format=custom:用來自定義這份文章列表的顯示樣式(fromat=custom也可以不要,默認以UL列表顯示文章標題。)
三、使用WP_Query函數(shù)
<?$post_query = new WP_Query('showposts=10');
while ($post_query->have_posts()) : $post_query->the_post();
$do_not_duplicate = $post->ID;
the_permalink(); the_title();
endwhile; ?>
注:在用WORDPRESS建站時最常用的是使用是第1種,便于美化網(wǎng)頁
未經(jīng)允許不得轉(zhuǎn)載:445IT之家 » wordpress建站:調(diào)用最新文章方法總結(jié)