wordpressだと標準でついてくるウィジェットで「最近投稿した記事」を表示できますが、これには投稿した日付が含まれていません。fc2ブログなど他のブログだと日付が表示され、最近よく書かれているブログかどうかの確認が出来ます。wordpressでも日付の表示が出来ないかな、と思って調べてみました。方法は以下の手順。
1.プラグイン「Customizable Post Listings」をインストールし、有効にする
2.ウィジェットでPHPを実行するために、プラグイン「Executable PHP widget」をインストールし、有効にする
3.「外観」-[ウィジェット]に「PHPCode」ウィジェットを追加する。タイトル:「最近投稿した記事」。内容は以下のphpコード。
<ul> <?php c2c_get_recent_posts( $num_posts = 10, $format = "<li>%post_URL% - %post_date%</li>", $categories = '', // space separated list of category IDs -- leave empty to get all $orderby = 'date', $order = 'DESC', // either 'ASC' (ascending) or 'DESC' (descending) $offset = 0, // number of posts to skip $date_format = 'Y年m月d日', // Date format, php-style, if different from blog's date-format setting $authors = '', // space separated list of author IDs -- leave empty to get all $post_status = 'publish', // space separated list of post_statuses to consider (possible values: publish, draft, private, and/or static) $include_passworded_posts = false); ?> </ul>
4.きちんと表示できているかどうか確認してみる。表示できていればOKです。
プラグイン「Customizable Post Listings」にある「c2c_get_recent_posts」という関数に与えるパラメタを調整することでいろいろできるようです。特定のカテゴリのみのリストを表示したり。今回は年まで含めた日付を表示したかったので
$date_format = 'Y年m月d日',
としました。色々なブログを検索していると、wordpressのカスタマイズ方法はたくさんかかれていますが年が古いとwordpress本体のバージョンが違ったり、プラグインのバージョンも全く違ったりしてうまくいかないことがあったので。
これで「更新しているブログ」だとさりげなくアピールできます。
———
参考リンク
Customizable Post Listingsの使い方(英語)Plugin: Customizable Post Listings | coffee2code.com
Customizable Post Listingsの使い方(日本語)power source* » WP plugin: 最近の投稿リストを表示 – Customizable Post Listings