您的当前位置:首页 > 知识博客 > wordpress建站

WordPress判断置顶文章函数:is_sticky

时间:2024-03-15

WordPress函数is_sticky用于判断当前文章是否置顶,在WordPress主题的制作中,可以通过判断文章是否置顶以应用不同的样式,例如加一个推荐的标签。

is_sticky(int $post_ID)

函数参数

$post_ID

整数,默认为空

文章的ID

函数使用示例

以下示例判断ID为66的文章是否设置了置顶:

if ( is_sticky(66) ) {
     // 文章已置顶
} else {
     // 文章没有置顶
}

扩展阅读

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

相关函数:

  • is_page()

  • is_singular()


欢迎咨询/Welcome to inquire
tel/vx:18842938855
qq:1685522781
email:1685522781@qq.com

Copyright © 2019-2024 sex.cyou


Whatsapp
Powered by RRZCMS