中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

wordpress置頂文章調(diào)用與設(shè)置

2018-11-02    來源:學(xué)做網(wǎng)站論壇

容器云強(qiáng)勢(shì)上線!快速搭建集群,上萬Linux鏡像隨意使用

wordpress網(wǎng)站后臺(tái)允許我們?cè)O(shè)置一些置頂文章,然后通過調(diào)用置頂文章的代碼把它調(diào)用到自己的網(wǎng)站前臺(tái)。

下面是最常用的wordpress調(diào)用置頂文章代碼,適用于所有模板使用。

<?php
$sticky = get_option('sticky_posts');
rsort( $sticky );
$sticky = array_slice( $sticky, 0, 5);
query_posts( array( 'post__in' => $sticky, 'caller_get_posts' => 1 ) );
if (have_posts()) :while (have_posts()) : the_post();
?>

<li><a href="<?php the_permalink(); ?>" target="_blank"><?php the_title(); ?></a></li>

<?php endwhile; endif; ?>

代碼解釋:

  • rsort( $sticky );?對(duì)置頂文章數(shù)組逆向排序,即大ID在前;
  • $sticky = array_slice( $sticky, 0, 5);控制顯示置頂文章的數(shù)量,輸出置頂文章數(shù),請(qǐng)修改5,0不要?jiǎng),如果需要全部置頂文章輸出,可以把這句注釋掉;
  • 'post__in' => get_option('sticky_posts')確定了該LOOP調(diào)用的是置頂文章列表。
  • 'caller_get_posts'的作用是排除非指定性文章,即除了置頂文章之外,不顯示其他的文章。

wordpress文章置頂方法

【后臺(tái)】--【文章】--【編輯】---【將文章置頂?shù)巾敳俊?/p>

wordpress調(diào)用置頂文章

相關(guān)教程:WP程序調(diào)用最新文章 熱門文章 相關(guān)文章 隨機(jī)文章代碼

標(biāo)簽: 代碼

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請(qǐng)與原作者聯(lián)系。

上一篇:WordPress網(wǎng)站mysql數(shù)據(jù)庫(kù)導(dǎo)入錯(cuò)誤的解決方法

下一篇:如何制作wordpress 手機(jī)網(wǎng)站