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

WordPress文章函數:is_single()

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

說明

wordpress 判斷一個單獨一面是否被顯示,返回 TRUE 或者 FALSE

用法

  1. <?php?is_single($post);??>

參數

$post

(mixed) (optional) Post ID, Post Title or Post Slug

默認: None

返回值

(boolean)

成功 True, 失敗 false.

示例

  1. is_single();
  2. //?當任何文章頁面被顯示.
  3. is_single('17');
  4. //?當文章ID為17的被顯示.
  5. is_single(17);
  6. //?當文章ID為17的被顯示。?整形的參數也可以。
  7. is_single('Irish?Stew');
  8. //?文章的標題為"Irish?Stew"的被顯示.
  9. is_single('beef-stew');
  10. //?當文章的別名?post_name?(slug)?是?"beef-stew"?的?被顯示.
  11. is_single(array(17,'beef-stew','Irish?Stew'));
  12. //?當文章的?ID是17,?或者別名?post_name?是?"beef-stew",或者文章的標題是"Irish?Stew"的返回True.??注意:?數組參數的功能是在?2.5版本添加的.

注意

類似功能: is_singular()

源文件

is_single() 在 wp-includes/query.php.

  1. /**
  2. ?*?Is?the?query?for?a?single?post?
  3. ?*
  4. ?*?Works?for?any?post?type,?except?attachments?and?pages
  5. ?*
  6. ?*?If?the?$post?parameter?is?specified,?this?function?will?additionally
  7. ?*?check?if?the?query?is?for?one?of?the?Posts?specified.
  8. ?*
  9. ?*?@see?is_page()
  10. ?*?@see?is_singular()
  11. ?*
  12. ?*?@see?WP_Query::is_single()
  13. ?*?@since?1.5.0
  14. ?*?@uses?$wp_query
  15. ?*
  16. ?*?@param?mixed?$post?Post?ID,?title,?slug,?or?array?of?such.
  17. ?*?@return?bool
  18. ?*/
  19. function?is_single(?$post?=?''?)?{
  20. ?global?$wp_query;
  21. ?if?(?!?isset(?$wp_query?)?)?{
  22. ??_doing_it_wrong(?__FUNCTION__,?__(?'Conditional?query?tags?do?not?work?before?the?query?is?run.?Before?then,?they?always?return?false.'?),?'3.1'?);
  23. ??return?false;
  24. ?}
  25. ?return?$wp_query->is_single(?$post?);
  26. }
  27. /**
  28. ??*?Is?the?query?for?a?single?post?
  29. ??*
  30. ??*?Works?for?any?post?type,?except?attachments?and?pages
  31. ??*
  32. ??*?If?the?$post?parameter?is?specified,?this?function?will?additionally
  33. ??*?check?if?the?query?is?for?one?of?the?Posts?specified.
  34. ??*
  35. ??*?@see?WP_Query::is_page()
  36. ??*?@see?WP_Query::is_singular()
  37. ??*
  38. ??*?@since?3.1.0
  39. ??*
  40. ??*?@param?mixed?$post?Post?ID,?title,?slug,?or?array?of?such.
  41. ??*?@return?bool
  42. ??*/
  43. ?function?is_single(?$post?=?''?)?{
  44. ??if?(?!$this->is_single?)
  45. ???return?false;
  46. ??if?(?emptyempty($post)?)
  47. ???return?true;
  48. ??$post_obj?=?$this->get_queried_object();
  49. ??$post?=?(array)?$post;
  50. ??if?(?in_array(?$post_obj->ID,?$post?)?)
  51. ???return?true;
  52. ??elseif?(?in_array(?$post_obj->post_title,?$post?)?)
  53. ???return?true;
  54. ??elseif?(?in_array(?$post_obj->post_name,?$post?)?)
  55. ???return?true;
  56. ??return?false;
  57. ?}
6 0

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

正版主題商店

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

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

服務熱線

wordpress建站咨詢