wordpress カスタム投稿を表示するカレンダープラグイン 2012年9月30日
Tag: |

サイドバーにカレンダーを表示する場合、カスタム投稿で作成された記事を表示するには、プラグインを使用すると便利です。

1.「WordPress Calendar For Custom Post Types」ここからダウンロードして、有効化します。

このプラグインはウィジェットに対応しているので、有効化したら、ダッシュボード – 外観 – ウィジェットで表示させたいカスタム投稿タイプを選択できます。
sidebar.phpのウィジェット表示部分に自動で挿入されます。

<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(1) ) : ?>
// ここに挿入される
	<?php endif; ?>

※注意:カスタム投稿の日付アーカイブはパーマリンクを設定していない場合は表示されません。

Custom Post Type Permalinks」こちらのプラグインで設定できます。

日付、月別アーカイブはdate.phpがあればそちらに表示されます。
date.phpがなければarchive.php又はindex.php 。archive.phpを複製してdate.phpを作成してもOK

2.私がハマッたカレンダーからのリンク先修正

カレンダーの日付からリンクされる日付アーカイブのリンク先がhttp://~/date/2012/09/30になってしまい、通常の投稿記事が表示されてしまう。
これをhttp://~/wordpress(カスタムタイプ名)/date/2012/09/30にするとちゃんと表示されたので、いろいろ探したらフォーラムで見つけました
ダッシュボード – プラグイン – Calendar Widget For Custom Post Typesの編集でプラグインファイルのpost-types-calendar/get_calendar.phpを修正
・日付アーカイブの場合
post-types-calendar/get_calendar.php内の

$calendar_output .= '<a href="' . get_day_link~//この部分を探して下記に変更
$calendar_output .= '<a href="' . $home_url . '/' . $post_type . '/date/' . $thisyear . '/' . $thismonth . '/' . $day . '" title="' . esc_attr( $ak_titles_for_day[ $day ] ) . "\">$day</a>";

・月別アーカイブの場合
post-types-calendar/get_calendar.php内の

if ( $previous ) {
        $calendar_output .= "\n\t\t".'~
//この部分を下記に変更
if ( $previous ) {
        $calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a href="' . $home_url . '/' . $post_type . '/date/' . $previous->year . '/' . $previous->month . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year)))) . '">&laquo; ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';
    } else {
        $calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
    }

    $calendar_output .= "\n\t\t".'<td class="pad">&nbsp;</td>';

    if ( $next ) {
        $calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a href="' . $home_url . '/' . $post_type . '/date/' . $next->year . '/' . $next->month . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month), date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) ) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' &raquo;</a></td>';
    } else {
        $calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
    }

New

Aechive

Tag

css Facebook facebookカスタマイズ Facebookページ font functions.php google NEWマーク RSS single.php webツール WEBデザインツール Wordpress アーカイブ カスタム カスタムフィールド カスタムフィールドテンプレート カスタム投稿 カテゴリー カレンダー サイドバー ターム テキスト テンプレートタグ プラグイン ヘッダ ページ ポップアップ メニュー 並び替え 並べ替え 人気 便利 分岐 印刷 年別アーカイブ 投稿 投稿記事 改行 文字数 文法チェック 最新記事 月別アーカイブ 特定カテゴリー 画像