Pages: 1 2

WordPress 2.0.5 Released

WordPress 2.0.5 - Ronan,Ronan 為慶祝其中一位開發者 Ryan Boren 新誕生兒子而取的名字。

WordPress 2.0.5 new and changed

Changelog,共有 54 個檔案更動,其中 1 個檔案為新增。[download]

升級至 WordPress 2.0.4

WordPress 2.0.4

WordPress 2.0.4 new and changed

共 74 個檔案更動、6 個檔案新增,包含不少安全性的修正,因此官方建議更新

左下角的 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 (%)', 'number'); ?>

/* 時間參數與留言數字格式可以自訂 */

2. 要注意的是,如果 get_posts 放在 The Loop 之前 (ex: 想把舊文章顯示在版面上方),則會連帶影響到首頁文章的顯示。以上面為例,分類 ID=1 的最新 3 篇文章也不會出現在首頁。這時,要使用 query_posts 將 The Loop 重置

先在 Theme 資料夾中的 index.php 找到 The Loop 的開頭:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

在 The Loop 之前,加入

<?php query_posts($query_string); ?>

這樣一來,才能讓首頁的文章正常顯示。

如果 get_posts 是出現在 The Loop 之後 (像我目前的配置),則不會影響,也不用 query_posts。

3. 當然,嫌麻煩的話,也可以使用 cypher Previous Posts 或是 Show Range Post 的 plugin 達到類似的簡單效果。

4. 問題待解: 如何把不想顯示的分類文章 (ex: Asides 的文章) 排除在外呢?


Pages: 1 2


About

You are currently browsing the hsuyo BLOG 2.0 weblog archives for the tag wordpress.

photo9 kuso8 wordpress6 wii6 nintendo6 diary6 youtube5 syslog5 travel4 ps34 good day3 game3 tv2 taiwan2 rumors2 plugin2 playstation 32 playstation2 pentax2 nds2 murmuring2 ipod nano2 hsnu2 flash2 final fantasy2 ffxiii2 ff132 fan made2 browser2 zidane1 wlm1 tips1 software1 ps21 poseidon1 playstation 21 photography1 opera1 nintendo ds1 ndsl1 movie1 mods1 mentos coke1 maxthon1 life1 k750i1 k10d1 japan1 google video1 gif1 firefox1 film1 feedburner1 engrish1 ds lite1 dairy1 culture1 commercial1 asides1 9111