[已失效]讓WordPress自動產生縮圖、特色圖片:Auto Post Thumbnail

2018/10/22:這個外掛已經「掛掉」很久了,等了一年多還是不能用,作者毫無說明放生我們,我們也放生這外掛吧。

相關文章

起因

因為「相關文章」外掛只有文字,所以我想找個可以自動把文章第一張圖變縮圖並呈現出來的方法,發現Wordpress早就有縮圖功能,只要使用the_post_thumbnail()這個函式就能達到!

參考「Post Thumbnail Support 主題增加文章縮圖功能」作好設定才發現要自己先幫每篇文章在主機建立縮圖(即編輯頁面右下角的「特色圖片」、featured image)……我所有文章都沒放特色圖片,而且我文章圖片都放在flickr,囧

Auto Post Thumbnail 與 Regenerate Thumbnail 雙劍合璧

後來在高登的網誌找到Thumbnail For Excerpts這個外掛,可以自動顯示縮圖,結果只能呈現在文章開頭……我不知道怎麼要抓出他的抓圖函式,所以找啊找,找到「Auto Post Thumbnail」這個插件!他會自動抓第一個插入的圖片存檔並產生縮圖~讚!

不過使用時尺寸沒設定好,所以我用regenerate thumbnail重新製作縮圖,結果不小心打錯尺寸……所以修改後重新產生一次!

標題提到的自動產生縮圖(外加產生過往文章的縮圖)大功告成!

 

相關文章外掛

2018/12/6:這個外掛已經兩年沒更新,wordpress官方頁面顯示「This plugin was closed on October 23, 2018 and is no longer available for download.」

我是使用Yet Another Related Posts Plugin產生「相關文章」,所以根據它內建的yarpp-template-example.php去修改。

<h3>Related Posts</h3>
<?php if ($related_query->have_posts()):?>
<ol>
<?php while ($related_query->have_posts()) : $related_query->the_post(); ?>
<li><a href=”<?php the_permalink() ?>” rel=”bookmark”><?php the_title(); ?></a><!– (<?php the_score(); ?>)–></li>
<?php endwhile; ?>
</ol>
<?php else: ?>
<p>No related posts.</p>
<?php endif; ?>

 

接著參考WordPress 日誌縮略圖功能找個地方放下面這類程式碼就好囉!

<a href=”<?php the_permalink(); ?>” rel=”bookmark” align=”center”><?php the_post_thumbnail(‘thumbnail’); ?></a>

外型我參考LinkWithin把清單列表改成橫排方塊,輔以一堆基礎的CSS語法,看起來還不賴。

You may also like

2 Responses

  1. Thomas表示:

    謝謝版大的介紹. 我也是用 Auto Post Thumbnail 這套自動縮圖 plugin, 不錯用!

    • 浩剛表示:

      我好一段時間沒有整頓Wordpress,不曉得有沒有新的、更好用的plugin呢!
      找時間要再來研究一下了~
      真的是好久好久沒有碰網頁了,有點懷念。

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.