Breadcrumb NavXT2.1.4で表示されるパンくずナビで、一部リンクがおかしいので修正した備忘録。
PHP4の関係でバージョンは2.1.4を使用しています。
月別アーカイブ表示の際は、(表示はUS式を選択)
Home > November 2008
と表示され自動的に年・月にそれぞれのリンクを付けてくれます。私のサイトの場合はホームURLに続いて
年:/2008
月:/2008/11
日:/2008/11/22
とすることでそれぞれのアーカイブページのリンクになるんですが、何故かこの2.1.4バージョンは、月別アーカイブだけが「/200811」となってしまい404ページが表示されてしまうんですよね・・・
これはちょっと頂けないので改造。
カスタマイズ
Breadcrumb NavXTフォルダ内のbreadcrumb_navxt_class.phpを修正431行目付近の
//Handle date based archives function do_archive_by_date()
と書かれているところを探し、自分の使いたい日時形式(US・EU・ISO)のコードを改造。全部しても別にかまわないけど。
私の場合はUS形式を選択しているので下記の部分
変更前
//If the date format is US style
if($this->opt['archive_date_format'] == 'US')
{
$this->breadcrumb['last']['prefix'] = $this->opt['archive_date_prefix'] .
'<a title="Browse to the ' . get_the_time('F') . ' ' . get_the_time('Y') .
' archive" href="' . get_year_link(get_the_time('Y')) . get_the_time('m') .
'">' . get_the_time('F') . '</a>' . ' ';
$this->breadcrumb['last']['item'] = get_the_time('jS');
$this->breadcrumb['last']['suffix'] = ', ' . ' <a title="Browse to the ' .
get_the_time('Y') . ' archive" href="' . get_year_link(get_the_time('Y')) .
'">' . get_the_time('Y') . '</a>' . $this->opt['archive_date_suffix'];
}
ただ6行目に「/」を追加するだけですがw
変更後
//If the date format is US style
if($this->opt['archive_date_format'] == 'US')
{
$this->breadcrumb['last']['prefix'] = $this->opt['archive_date_prefix'] .
'<a title="Browse to the ' . get_the_time('F') . ' ' . get_the_time('Y') .
' archive" href="' . get_year_link(get_the_time('Y')) .'/'. get_the_time('m') .
'">' . get_the_time('F') . '</a>' . ' ';
$this->breadcrumb['last']['item'] = get_the_time('jS');
$this->breadcrumb['last']['suffix'] = ', ' . ' <a title="Browse to the ' .
get_the_time('Y') . ' archive" href="' . get_year_link(get_the_time('Y')) .
'">' . get_the_time('Y') . '</a>' . $this->opt['archive_date_suffix'];
}
こんな感じで月別アーカイブのリンクを設定する事で、ちゃんと表示できるようになりました
Dec
4:47
2008.11.18
207 views
注意















