Archive for May, 2006
[via]
[WP] 利用 get_posts 得到 Previous Posts
3 Comments Published by hsuyo 5:03 PM, May 31st, 2006 in WordPress左下角的 Previous Posts,是用 get_posts 得到的小型文章 loop。
1. 基本的用法:
<?php
$posts = get_posts('numberposts=5&offset=3&category=1');
foreach($posts as $post) :
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
/* numberposts= 指定文章數量; offset= 顯示第 n 篇後的文章; category= 指定分類 (0=不指定) */
則會顯示分類 ID=1 之中,去掉最新 3 篇文章之後的 5 篇文章標題連結;
若要加入文章的日期跟留言,則在 <?php the_title(); ?> 與 </a> 之間加入:
<?php the_time('F jS, Y'); ?> <?php comments_number('| No comments yet','| Comments (1)','| Comments […]
原本右下角的 Asides (漂流木) 是用 plugin: sideblog 來做,但使用後,會與 Ultimate Tag Warrior 相衝突,造成 tag 連結內的文章找不到的情形。
於是用回老方法: Front Page Categories 指定首頁文章的分類,再用 Customizable Post Listings 去抓 asides 分類的文章。
這樣一來,就沒有上述的 posts not found 問題了。
About
You are currently browsing the hsuyo BLOG 2.0 weblog archives for May, 2006.
Longer entries are truncated. Click the headline of an entry to read it in its entirety.