In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the wordpress is_sticky () how to judge whether the article is the top of the parameters and usage, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
[description]
Check whether the current article is at the top. Returns a value of TRUE or FALSE.
[usage]
The code is as follows:
[parameters]
$post_ID
(string) (optional) Article ID
Default: None
Return value
(boolean)
True, or false.
[example]
The code is as follows:
Is_sticky (); / / any top article is displayed.
Is_sticky ('17'); / / when articles with an ID of 17 are displayed.
[source file]
Is_sticky () is located in wp-includes/post.php.
PHP Code copies content to the clipboard
/ * Check if post is sticky. * * Sticky posts should remain at the top of The Loop. If the post ID is not * given, then The Loop ID for the current post will be used. * * @ since 2.7.0 * * @ param int $post_id Optional. Post ID. * @ return bool Whether post is sticky. * / function is_sticky ($post_id = 0) {$post_id = absint ($post_id); if (! $post_id) $post_id = get_the_ID (); $stickies = get_option ('sticky_posts'); if (! Is_array ($stickies)) return false; if (in_array ($post_id, $stickies)) return true; return false;}
Here are some examples:
Is_sticky (10) is to determine whether an article with a $post_id of 10 is a top article, not a top article with a post_id of 10 in all top articles. The reason why there is a wrong understanding of the latter is that I read the official introduction of the is_sticky ($post_id) method in French. In fact, after a close study, "all the articles with a post_id of 10 in the top article" is also superfluous. Directly $post- > id==10 or get_the_id () = 10 to determine whether the current article $post_id is equal to 10!
I would also like to thank brother tiandi in Youchuan for reminding me that there is no problem of "invalid parameters in is_sticky ($post_ID)" and correcting his misunderstanding of the wordpress is_sticky ($post_id) method.
Thank you for reading this article carefully. I hope the article "how to judge the parameters and usage of is_sticky () in wordpress" shared by the editor is helpful to everyone. At the same time, I also hope you can support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.