女武神的终末第三季免费观看,国产精品va无码二区,欧美日韩在线视频观看,国产在线观看网站

wordpress檢查文章是否置頂函數(shù):is_sticky()

2016-10-16 wordpress函數(shù)
  • 文章介紹
  • 快速入門(mén)
  • 評(píng)價(jià)&建議

說(shuō)明

wordpress 檢查當(dāng)前文章是否置頂。返回值TRUE 或者 FALSE.

用法

  1. <?php?is_sticky($post_ID);??>

參數(shù)

$post_ID

(string) (optional) 文章 ID

默認(rèn): None

返回值

(boolean)

True,或 false.

示例

  1. is_sticky();
  2. //?任意置頂文章被顯示.
  3. is_sticky('17');
  4. //?當(dāng)ID為17的文章被顯示.

源文件

is_sticky() 位于 wp-includes/post.php.

  1. /**
  2. ?*?Check?if?post?is?sticky.
  3. ?*
  4. ?*?Sticky?posts?should?remain?at?the?top?of?The?Loop.?If?the?post?ID?is?not
  5. ?*?given,?then?The?Loop?ID?for?the?current?post?will?be?used.
  6. ?*
  7. ?*?@since?2.7.0
  8. ?*
  9. ?*?@param?int?$post_id?Optional.?Post?ID.
  10. ?*?@return?bool?Whether?post?is?sticky.
  11. ?*/
  12. function?is_sticky(?$post_id?=?0?)?{
  13. ?$post_id?=?absint(?$post_id?);
  14. ?if?(?!?$post_id?)
  15. ??$post_id?=?get_the_ID();
  16. ?$stickies?=?get_option(?'sticky_posts'?);
  17. ?if?(?!?is_array(?$stickies?)?)
  18. ??return?false;
  19. ?if?(?in_array(?$post_id,?$stickies?)?)
  20. ??return?true;
  21. ?return?false;
  22. }
3 0

企業(yè)建站推薦正版商業(yè)主題,國(guó)內(nèi)專(zhuān)業(yè)團(tuán)隊(duì)開(kāi)發(fā),完善售后,是您不二選擇。

正版主題商店

主題貓WP建站,累計(jì)幫助1300+客戶(hù)成功建站,為站長(zhǎng)提供支持!

立刻開(kāi)啟你的建站之旅
QQ在線客服

服務(wù)熱線

wordpress建站咨詢(xún)