全国ライブカメラの旅 第655回
2010年9月6日 – 17:09 | コメントは受け付けていません。

MOBOTIX特集
イタリア、ラベンナ -7時間
http://bagnodelfino.com/
コントロール不可、固定
機種 MOBOTIX D12
http://82.91.122.189:8003/cgi-b [...]

全文表示 Read the full story »
openSUSE

openSUSE11.2にバージョンアップ(2009.12.11)。DELL Power Edge 860 SAS 5/i5 RAID1 で稼働中。     

WordPress

プラグイン、テーマ、日本語化などWordPressって本当によく遊べます。設定などの覚書。

リンクサイト

北海道、東京、山口、宮崎他のライブカメラ関係サイトとお世話になっているサイトです。

全国ライブカメラの旅

検索でライブカメラを見つけて紹介しております。国内、海外のPanasonicを中心に紹介。

覚 書

いろいろ役に立つような情報を忘れないように覚書しております。いたって自分用です……

Home » WordPress

monthchunks plugin for WordPress

Submitted by さんきゅう on 2009年2月24日 – 17:07コメント無

月別アーカイブをコンパクトに表示。 :cool:
monthchunks plugin for WordPress http://justinsomnia.org/2005/04/monthchunks-howto/
左列真ん中くらいに 
Instructions
  Download and unzip monthchunks-2.1.zip (v2.1)
ダウンロード後 /wp-content/plugins/ へアップ、有効。
うちのテーマでは <?php wp_get_archives(‘type=monthly’); ?> は使ってない。

/wp-includes/widgets.php
801行目を変更。

/**
 * Display archives widget.
 *
 * @since 2.2.0
 *
 * @param array $args Widget arguments.
 */
function wp_widget_archives($args) {
	extract($args);
	$options = get_option('widget_archives');
	$c = $options['count'] ? '1' : '0';
	$d = $options['dropdown'] ? '1' : '0';
	$title = empty($options['title']) ? __('Archives') : apply_filters('widget_title', $options['title']);
 
	echo $before_widget;
	echo $before_title . $title . $after_title;
 
	if($d) {
?>
		<select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> <option value=""><?php echo attribute_escape(__('Select Month')); ?></option> <?php wp_get_archives("type=monthly&format=option&show_post_count=$c"); ?> </select>
<?php
	} else {
?>
		<ul>
		<?php monthchunks("descending"); ?>  //変更、オプションのdescendingで新年度が上に表示
		</ul>
<?php
	}
 
	echo $after_widget;
}

一桁月の前にゼロをつける。
参考先 「月別アーカイブをコンパクトにするプラグイン「monthchunks」」 :shock:
http://www.wp-guide.net/wpplugin/wphyouji/150.html
/wp-content/plugins/monthchunks-2.1/monthchunks.php
76、97行目変更

function monthchunks($year_order = "ascending", $month_format = "numeric")
{
    // get access to wordpress' database object
    global $wpdb;
    $current_month = "";
    $current_year  = "";

    // get current year/month if current page is monthly archive
    if (is_month())
    {
        $current_month = get_the_time('m');  //変更
        $current_year  = get_the_time('Y');
    }
 
    // set SQL order by sort order
    if ($year_order == "descending")
    {
        $year_order = "DESC";
    }
    else
    {
        $year_order = "ASC";
    }
 
    // set format for month display
    if ($month_format == "alpha")
    {
        $month_format = "LEFT(DATE_FORMAT(post_date, '%M'), 1)";
    }
    else
    {
        $month_format = "DATE_FORMAT(post_date, '%m')";  //変更
    }

archives.jpg
最終は
参考ページ
monthchunksの表記を日本語にしてみた http://blog.open-arms.biz/200805/06422.php

        // start the list item displaying the year
        $year_= $year ."年";
        print "<li><strong>$year_</strong><br />\n";

        // loop through each month, creating a link
        // followed by a single space
        $month_count = count($months);
        $i = 0;
        foreach($months as $month)
        {
            // display the current month in bold without a link
            if ($year == $current_year && $month->post_month == $current_month)
            {
                $month_ = $month->display_month . "月";
                print "<strong title='$month->post_month_name $year'>$month_</strong>";
            }
            else
            {
                $month_ = $month->display_month . "月";
                print "<a href='" . get_month_link($year, $month->post_month) . "' title='$month->post_month_name $year'>" . $month_ . "</a>";
            }

            if ($i < $month_count-1)
            {
                print " \n";
            }
            $i++;
        }

        //end the year list item
        print "</li>\n\n";
    }
}

?>

Popularity: 1% [?]

Comments are closed.