欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

wordpress get_posts函數(shù)的使用方法 禁止輸出指定類別的文章

  發(fā)布時(shí)間:2013-11-13 15:48:08   作者:佚名   我要評(píng)論
本文向大家介紹wordpress使用get_posts函數(shù)功能禁止輸出指定類別文章的方法,大家可以參考一下
使用wordpress禁止輸出指定類別的文章可以給get_posts()函數(shù)傳個(gè)數(shù)組參數(shù),如下:

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

<div class="widget" id="diary1">
<h3>隨機(jī)呈現(xiàn)</h3>
<ul>
<?php
$args=array(
'numberposts'=>16,
'category'=>'-9,-12',
'orderby'=>'rand'
);
$rand_posts = get_posts($args);
foreach( $rand_posts as $post ) :
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
</div>

其中:

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

$args=array(
'numberposts'=>16,
'category'=>'-9,-12',
'orderby'=>'rand'
);

鍵名numberposts表示取出的文章數(shù),category表示要顯示的文章的類別ID,負(fù)數(shù)代表不顯示,以字符串的形式用逗號(hào)隔開(kāi),orderby這里表示隨機(jī)取出文章。
效果如小談博客首頁(yè)右側(cè)“隨機(jī)呈現(xiàn)”效果,去掉了php類別的文章顯示,因?yàn)橄旅嬗辛艘粋€(gè)“php專欄”,避免重復(fù)。
get_posts()函數(shù)完整的參數(shù)列表:

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

<?php $args = array(
'posts_per_page' => 5,
'numberposts' => 5,
'offset' => 0,
'category' => '',
'orderby' => 'post_date',
'order' => 'DESC',
'include' => '',
'exclude' => '',
'meta_key' => '',
'meta_value' => '',
'post_type' => 'post',
'post_mime_type' => '',
'post_parent' => '',
'post_status' => 'publish',
'suppress_filters' => true );
?>

相關(guān)文章

  • WordPress 防止惡意評(píng)論的方法

    本文章詳細(xì)的介紹了關(guān)于WordPress 防止惡意評(píng)論代碼處理辦法
    2013-11-10
  • Wordpress 商業(yè)模板源碼 php版 v1.7

    支持網(wǎng)友爆料功能,后臺(tái)可以設(shè)置是否要登錄才能爆料、爆料是否直接發(fā)布、前后爆料間隔時(shí)間
    2013-08-08
  • 藍(lán)色簡(jiǎn)約輕博客simple-blue模版 v1.0 For WordPress

    之前看到這個(gè)樣式的博客很喜歡,這次用了幾天時(shí)間用WP移植(仿)過(guò)來(lái),感覺(jué)還不錯(cuò),雖然沒(méi)有側(cè)邊欄有點(diǎn)不爽,但是畢竟是輕博客風(fēng)格,有沒(méi)有也就無(wú)所謂了
    2013-06-26
  • WordPress(手機(jī)博客系統(tǒng)) v24.1 安卓版

    WordPress是使用PHP語(yǔ)言開(kāi)發(fā)的博客平臺(tái),用戶可以隨時(shí)隨地管理自己的WordPress網(wǎng)站,WordPress具有易用性和靈活性的特點(diǎn),它提供了一個(gè)廣泛的主題和插件庫(kù),使得用戶能夠輕
    2024-02-20
  • wp-syntax WordPress 代碼高亮插件 v1.0

    WP-Syntax 是一個(gè)針對(duì) Wordpress 的代碼高亮插件,最大的優(yōu)點(diǎn)是簡(jiǎn)單易用,兼容性非常好
    2013-05-18

最新評(píng)論