In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is about judging, adding, and removing PHP functions from WordPress top articles. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Judge the article at the top
The is_sticky () function is used to determine whether an article is the top article.
Usage
Is_sticky ($post_id)
Parameters.
$post_id
(integer) (optional) the article ID to be judged is the current article in the loop by default.
Default value: 0 (current article in the loop)
Return value
(Boolean) whether the article is at the top.
Examples
If (is_sticky ()) echo / / 'current article is top article'; if (is_sticky (68)) echo / / 'articles with ID of 68 are top articles'
Other
This function is located at: wp-includes/post.php
Add and remove functions for top articles
WordPress supports articles at the top by default, and you can put important or wonderful articles at the top in the background for users to see first.
In development, you may need to add and remove top articles through code. The principle of the WordPress top article is to store the ID of the top article in the options table, and you can control the top article by modifying the sticky_posts field.
However, WordPress provides two functions that make it easier to add and remove top articles, and directly call the function to modify the sticky_posts field.
Stick_post ()
The stick_post () function is used to top an article, for example:
Stick_post (68); / / articles with an ID of 68 stick_post (get_the_ID ()); / / current articles in the top loop
Unstick_post ()
The unstick_post () and stick_post () functions, in contrast, are used to untop a top article:
Unstick_post (425); / / unset the article unstick_post (get_the_ID ()) with the top ID of 425; / / cancel the current article in the top loop. Thank you for reading! This is the end of this article on "judging, adding and deleting PHP functions of WordPress Top articles". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
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.