サイトパスとだいたい同じパンくずリストを出力する関数を作りました。以下のコードを wp.vicuna/function.php に追加します。
/**
* パンくずリストを出力します
*/
function print_topic_path( $indent = 2 ) {
$indentText = '';
for ($i = 0; $i < $indent; $i ++)
$indentText .= "\t";
echo $indentText. '<p class="topicPath">'. "\n";
if( is_home() ) {
echo $indentText. "\t". '<span class="current">Home</span>'. "\n";
} else {
echo $indentText. "\t". '<a href="'. get_bloginfo('home'). '" title="Home">Home</a> > '. "\n";
if( is_single() ) {
echo $indentText. "\t". '<a href="'. get_bloginfo('home'). get_the_time('/Y/' ). '">'. get_the_time('Y'). '</a> > '. "\n";
echo $indentText. "\t". '<a href="'. get_bloginfo('home'). get_the_time('/Y/m/'). '">'. get_the_time('m'). '</a> > '. "\n";
echo $indentText. "\t". '<span class="current">'. the_title( '', '', false ). '</span>'. "\n";
} elseif( is_page() ) {
$parent_pages = get_page_parent('sort_column=menu_order');
if ($parent_pages) {
echo $indentText. "\t". $parent_pages. ' > '. "\n";
}
echo $indentText. "\t". '<span class="current">'. the_title( '', '', false ). '</span>'. "\n";
} elseif( is_category() ) {
echo $indentText. "\t". 'Categories > '. "\n";
if ($categories = get_category_only_parents($cat, ' | ') ) {
echo $indentText. "\t". $categories. ' > '. "\n";
}
echo $indentText. "\t". '<span class="current">'. single_cat_title( '', false ). '</span>'. "\n";
} elseif( is_archive() ) {
$topicPathList = explode( '-', get_archive_title() );
$topicPathURL = get_bloginfo('home'). '/';
for( $i = 0; $i < ( count( $topicPathList ) - 1 ); $i++ ) {
$topicPathURL .= (string)( $topicPathList[$i] ). '/';
echo $indentText. "\t". '<a href="'. $topicPathURL. '">'. (string)( $topicPathList[$i] ). '</a> > '. "\n";
}
echo $indentText. "\t". '<span class="current">'. (string)( $topicPathList[$i] ). '</span>'. "\n";
} elseif( is_search() ) {
echo $indentText. "\t". '<span class="current">Search</span>'. "\n";
} elseif( is_404() ) {
echo $indentText. "\t". '<span class="current">Error 404</span>'. "\n";
}
}
echo $indentText. '</p>'. "\n";
return;
}
あとは、パンくずリストを入れたいところに <?php print_topic_path(); ?> を入れるだけ。
まだ、ページ機能には対応していないです。今後、出来るなら対応したいです。