">

久久久精品2019免费观看_亚洲国产精品成人久久久_69国产成人综合久久精品91_国产精品久久精品视

wordpress建站:調(diào)用最新文章方法總結(jié)

方法一、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é)

贊 (0) 打賞

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

微信掃一掃打賞