sticky_class

函式
sticky_class ( $post_id = null )
引數
  • (int) $post_id An optional post ID.
    Required:
    Default: null
相關
  • post_class()
定義位置
相關方法
post_classbody_classstick_postget_body_classget_post_class
引入
2.7.0
棄用
3.5.0

sticky_class: 這是一個WordPress的函式,用於返回用於粘性文章的CSS類。它需要兩個引數,$class和$post_id。$class引數指定了用於粘性文章的CSS類。如果當前的文章是粘性的,它返回帶有”-sticky”字尾的$class引數,否則,它返回一個空字串。

顯示"sticky"CSS類,如果一個文章是粘性的。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function sticky_class( $post_id = null ) {
_deprecated_function( __FUNCTION__, '3.5.0', 'post_class()' );
if ( is_sticky( $post_id ) )
echo ' sticky';
}
function sticky_class( $post_id = null ) { _deprecated_function( __FUNCTION__, '3.5.0', 'post_class()' ); if ( is_sticky( $post_id ) ) echo ' sticky'; }
function sticky_class( $post_id = null ) {
	_deprecated_function( __FUNCTION__, '3.5.0', 'post_class()' );
	if ( is_sticky( $post_id ) )
		echo ' sticky';
}

常見問題

FAQs
檢視更多 >