久青草国产观看在线视频,在线观看欧美日女,777毛片,亚洲国产精品99久久久久久久

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

2016-10-16 wordpress函數
  • 文章介紹
  • 快速入門
  • 評價&建議

說明

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

用法

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

參數

$post_ID

(string) (optional) 文章 ID

默認: None

返回值

(boolean)

True,或 false.

示例

  1. is_sticky();
  2. //?任意置頂文章被顯示.
  3. is_sticky('17');
  4. //?當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

企業建站推薦正版商業主題,國內專業團隊開發,完善售后,是您不二選擇。

正版主題商店

主題貓WP建站,累計幫助1300+客戶成功建站,為站長提供支持!

立刻開啟你的建站之旅
QQ在線客服

服務熱線

wordpress建站咨詢