欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

WordPress

當(dāng)前位置:主頁 > CMS教程 > WordPress >

wordpress獲取置頂文章列表的方法

來源:本站原創(chuàng)|時間:2020-01-11|欄目:WordPress|點(diǎn)擊: 次

首先,你需要了解query_posts函數(shù)。該函數(shù)的作用就是對文章進(jìn)行檢索、挑選、排序,在其后的LOOP循環(huán)中使用經(jīng)過挑選、排序的文章。例如:


復(fù)制代碼
代碼如下:

<?php
query_posts('posts_per_page=10&ignore_sticky_posts=1&orderby=rand');
while(have_posts()):the_post();
echo '<li>';the_title();echo '</li>';
endwhile;
wp_reset_query();

將隨機(jī)列出一條文章的標(biāo)題。至于query_posts的具體參數(shù),請參考開發(fā)手冊。

接下來,我們就是要通過對query_posts的參數(shù)進(jìn)行調(diào)整,挑選出置頂?shù)奈恼铝斜砹恕?/p>


復(fù)制代碼
代碼如下:

$query_post = array(
'posts_per_page' => 10,
'post__in' => get_option('sticky_posts'),
'caller_get_posts' => 1
);
query_posts($query_post);
?>
<ul style="display:none;">
<?php while(have_posts()):the_post(); ?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
<?php
wp_reset_query();

參數(shù)用一個數(shù)組的形式放在$query_post中,關(guān)鍵的參數(shù)為'post__in' =>get_option('sticky_posts')和'caller_get_posts' => 0。

'post__in' => get_option('sticky_posts')確定了該LOOP調(diào)用的是置頂文章列表。'caller_get_posts'的作用是排除非指定性文章,即除了置頂文章之外,不顯示其他的文章。(不添加的情況下,如果置頂文章條目不足'posts_per_page'規(guī)定的值,會用最新文章替補(bǔ)完整。)

上一篇:WordPress站點(diǎn)實(shí)現(xiàn)分類目錄訂閱功能實(shí)例

欄    目:WordPress

下一篇:WordPress上傳文件存放到不同目錄的方法

本文標(biāo)題:wordpress獲取置頂文章列表的方法

本文地址:http://mengdiqiu.com.cn/a1/WordPress/12774.html

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請與我們聯(lián)系,我們將在24小時內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有