DC’s nicer archives の EXPAND が作動しない
-
いま、同プラグインを久しぶりにインストールしてみて確認しました。
症状としては、カテゴリを選んだ場合にそうなるのではありませんか?月別アーカイブ、検索結果、ではうまく動いていました。
もしカテゴリだけでそうなるのであれば、nicer_archives.php のカテゴリ別表示の部分を以下にすればとりあえず回避できます。function cat_header_link() { global $posts, $post; $id = $_GET['cat']; if (!is_full() && (count($posts) > 0)) { $output = ' ('.count($posts).') <a href="'.get_category_link($id) .'&full=1" rel="bookmark" title="Permanent Link: '.$category_name. '">Expand</a>';} elseif (count($posts) > 0) {$output = ' ('.count($posts).') <a href="'.get_category_link($id) .'" rel="bookmark" title="Permanent Link: '.$category_name. '">Collapse</a>';} else {$output = $category_name.' ('.count($posts).')';} return $output; }
これは良いかどうかは別としても、当方では動作しています。
返信有難うござます。
まず検索では上手くいっています。
それからカテゴリは紹介して頂いたコードで親カテゴリの総合は表示されませんが、その下のカテゴリは表示されるようになったので助かりました。残った問題は、月別のアーカイブはタイトルと親カテゴリーが一緒に一覧表示されますが、EXPAND が機能しません。
またカレンダーの日付をクリックすると一件表示されますが、こちらも EXPAND が機能しません。ただこの場合、出来れば開いた状態で普通に表示したい。
あとカテゴリにも EXPAND 機能を使えたらいのですが可能でしょうか。宜しくお願いします。
ダウンロードした default フォルダの category.php をそのまま使うと以下のようなエラーメッセージが表示されます。
Archive for the ‘総合’ Category
Catchable fatal error: Object of class WP_Error could not be converted to string in C:\xampp\htdocs2\wp\wp-content\plugins\nicer_archives.php on line 34
それを回避する為、以下の様に category.php の一部を使っているテーマのコードと入れ替えています。元の category.php
<?php get_header(); ?>
<div id=”content” class=”narrowcolumn”>
<?php if (have_posts()) : ?>
<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
<?php /* If this is a category archive */ if (is_category()) { ?>
<h2 class=”pagetitle”>Archive for the ‘<?php echo single_cat_title(); ?>’ Category <?php echo cat_header_link(); ?></h2>
<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
<h2 class=”pagetitle”>Archive for <?php the_time(‘F jS, Y’); echo mo_header_link(); ?></h2>
<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
<h2 class=”pagetitle”>Archive for <?php the_time(‘F, Y’); echo mo_header_link();?></h2>
<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
<h2 class=”pagetitle”>Archive for <?php the_time(‘Y’); echo mo_header_link(); ?></h2>
<?php /* If this is a search */ } elseif (is_search()) { ?>
<h2 class=”pagetitle”>Search Results</h2>
<?php /* If this is an author archive */ } elseif (is_author()) { ?>
<h2 class=”pagetitle”>Author Archive</h2>
<?php /* If this is a paged archive */ } elseif (isset($_GET[‘paged’]) && !empty($_GET[‘paged’])) { ?>
<h2 class=”pagetitle”>Blog Archives</h2>
<?php } ?>
<?php
if ( !is_full() ) {
echo ‘- ‘;
if ($posts) {
start_wp();
foreach ($posts as $post) { ?>- ID) ?>” rel=”bookmark” title=”Permanent Link: <?php echo $post->post_name; ?>”><?php echo $post->post_title; ?>
- No matches for
<?php }
}
else { echo ‘‘;}
echo ‘
‘;
}
else { include “full.php”;}
else : ?>
<h2 class=”center”>Not Found</h2>
<?php include (TEMPLATEPATH . ‘/searchform.php’); ?>
<?php endif; ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>変更した category.php
<?php get_header(); ?>
<div id=”content” class=”narrowcolumn”>
<?php if (have_posts()) : ?>
<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
<?php /* If this is a category archive */ if (is_category()) { ?>
<h2 class=”pagetitle”><?php printf(__(‘Archive for the ‘%s’ Category’, ‘kubrick’), single_cat_title(”, false)); ?></h2>
<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
<h2 class=”pagetitle”>Archive for <?php the_time(‘F jS, Y’); echo mo_header_link(); ?></h2>
<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
<h2 class=”pagetitle”>Archive for <?php the_time(‘F, Y’); echo mo_header_link();?></h2>
<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
<h2 class=”pagetitle”>Archive for <?php the_time(‘Y’); echo mo_header_link(); ?></h2>
<?php /* If this is a search */ } elseif (is_search()) { ?>
<h2 class=”pagetitle”>Search Results</h2>
<?php /* If this is an author archive */ } elseif (is_author()) { ?>
<h2 class=”pagetitle”>Author Archive</h2>
<?php /* If this is a paged archive */ } elseif (isset($_GET[‘paged’]) && !empty($_GET[‘paged’])) { ?>
<h2 class=”pagetitle”>Blog Archives</h2>
<?php } ?>
<?php
if ( !is_full() ) {
echo ‘- ‘;
if ($posts) {
start_wp();
foreach ($posts as $post) { ?>- <?php the_category(‘ ‘);ハ?> in ID) ?>” rel=”bookmark” title=”Permanent Link: <?php echo $post->post_name; ?>”><?php echo $post->post_title; ?>
- No matches for
<?php }
}
else { echo ‘‘;}
echo ‘
‘;
}
else { include “full.php”;}
else : ?>
<h2 class=”center”>Not Found</h2>
<?php endif; ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>と、上記のような事をしたんですが、問題ありませんか?
宜しくお願いいたします。無理を言って申し訳ありませんでした。
この DC’s nicer archives には一部不満な点、EXPAND は各タイトルごとに開閉が出来ないという事があって、easy-start-pack というプラグインにアコーディオン機能があるので、それを使って試したところタイトル一覧を表示して各タイトルごとに開閉が出来る様になりました。
変更は archive.php の以下の部分を
<?php while (have_posts()) : the_post(); ?>
<div <?php post_class(); ?>>
<h3 id=”post-<?php the_ID(); ?>” class=”accordion_title”><!–” rel=”bookmark” title=”<?php printf(__(‘Permanent Link to %s’, ‘kubrick’), the_title_attribute(‘echo=0’)); ?>”><?php the_title(); ?><?php the_time(__(‘l, F jS, Y’, ‘kubrick’)) ?></h3>
<small><?php the_time(__(‘l, F jS, Y’, ‘kubrick’)) ?></small>
<div class=”entry”>
<?php the_content() ?>
</div>
以下の様に変えて
<?php while (have_posts()) : the_post(); ?>
<div <?php post_class(); ?>>
<h3 id=”post-<?php the_ID(); ?>” class=”accordion_title”><span class=”span_ymd”><?php the_time(__(‘l, F jS, Y’, ‘kubrick’)) ?></span></h3>
<div class=”accordion_body”>
<?php the_content() ?>
</div>
後は css を調整するだけです。
こちらの方が簡単で各タイトルごとに開閉が出来るのでいいと思いました。
ただ上記の様にリンクを外さないと上手くいきません。
タイトルの下に開閉のボタンを付けてみましたが駄目で、今後の検討課題です。
デザインを付けて近いうちにアップします。
今回もお相手くださり大変感謝しています。有難うございました。
- トピック「DC’s nicer archives の EXPAND が作動しない」には新たに返信することはできません。