用WP-Sticky做文章置頂及高亮

Wordpress

http://lesterchan.net/wordpress/readme/wp-sticky.html

本篇介紹WP-Sticky的用法。他有兩種功能,分別叫做Announcement Posts和Sticky Posts,所謂的Announcement Posts就是會永遠在最上方,而Sticky Posts則是在「當日」最上方。

以下範例來自官方,可以很清楚表達兩者差異。

Announcement
- Post 5 (Announcement Post)

29th March 2007
- Post 6
- Post 7
- Post 8

28th March 2007
- Post 4 (Sticky Post)
- Post 1
- Post 2
- Post 3

用法

打開佈景原始檔,輸入想要的東西,如下。

The Post Sticky Status

<?php post_sticky_status($before,$after); ?>
$before 文字之前要出線的字
$after 文字之後要出線的字

Announcement Banner

如果你的佈景使用the_date();,這東西會自動出現,如果沒出現的話,可以手動加上:
<?php announcement_banner(); ?>

判斷是否為置頂文章

<?php
   if(is_announcement()):
      // If post is an Announcement
   else:
      // If post is NOT an Announcement
   endif;
?> 

以此類推

<?php
   if(is_stickied()):
      // If post is Sticky
   else:
      // If post is NOT Sticky
   endif;
?> 

用CSS美化

CSS的class分別是sticky_post和announcement_post。

回應

麻烦介绍下这个插件的功能好不?呵呵
很佩服你这么有技术天分的丫头We're sorry, but the spam filter thinks your submission could be spam. Please complete the CAPTCHA.

發表新回應

這個欄位的內容會保密,不會公開顯示。 If you have a Gravatar account, used to display your avatar.
  • 自動將網址與電子郵件位址轉變為連結。
  • 可使用的 HTML 標籤:<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • 自動斷行和分段。

更多關於格式選項的資訊