WordPress のコメントスレッド表示に対応。

一応、ul でテンプレを書き直してはみたものの、なんとなくデザインが気に入らない。
…っつか、上手くいかない。
で、またネットの海をふらふらしてたらピンポイントなエントリを発見。
参考サイト : WordPress、vicuna CMSテーマのコメント欄をスレッド表示に対応させた : Hinemosu
いやいや、まさしくそのまんまじゃないっすかーw
ちゅうわけで、そのままパクら…いや、引用させていただきました。
ただ、comment-reply.js の部分が上手く動作しなかったのでそこんとこだけ修正。
このJavaScript が何やってるかっつーと、デフォルトのテンプレで試してみるとわかります。
ま、要するに、返信の場合はコメントフォームが返信元のコメントの下に移動するわけです。

修正前:

<?php function custom_comments($comment, $args, $depth) {
	$GLOBALS['comment'] = $comment;
?>
<li id="comment<?php comment_ID() ?>">
	<span class="commentImg"><?php echo get_avatar( $comment, 40 ); ?><br />
	<small><?php comment_author_link() ?></small></span>
	<?php comment_text() ?>
	<small class="commentmetadata">
		<a href="#comment<?php comment_ID() ?>" class="date"><?php comment_date(__('y-m-d (D) G:i', 'vicuna')) ?></a>
		<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'reply_text' => '返信', 'before' => ' | ', 'after' => ' | ') ) ); ?>
		<?php edit_comment_link(__('Edit', 'vicuna'), '<span class="admin">', ''); ?>
	</small>
<?php
}
?>

修正後:

<?php function custom_comments($comment, $args, $depth) {
	$GLOBALS['comment'] = $comment;
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
	<div id="comment-<?php comment_ID() ?>">
		<span class="commentImg">
			<?php echo get_avatar( $comment, 40 ); ?><br />
			<small><?php comment_author_link() ?></small>
		</span>
		<?php comment_text() ?>
		<small class="commentmetadata">
			<a href="#comment<?php comment_ID() ?>" class="date"><?php comment_date(__('y-m-d (D) G:i', 'vicuna')) ?></a>
			<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'reply_text' => '返信', 'before' => ' | ', 'after' => ' | ') ) ); ?>
			<?php edit_comment_link(__('Edit', 'vicuna'), '<span class="admin">', ''); ?>
		</small>
	<div>
<?php
}
?>

liタグのclassを追加して、idを変更。
その後、コメント部分をdivで囲って、liにふられていたidに変更。
cssはもともとclassに対して定義されてないので変更の必要なしです。
これでたぶん上手く動作するはず…。
いろいろいじってたらわかんなくなってしまった(汗)
試してみたサイトは 烏白馬角 デス。
#あー…はやいとこかっぱ堂.jpに適用しねぇと…w

Related posts:

  1. wp.Vicuna.Ext で Plugin : Commented entry list を使用する場合のカスタマイズ
  2. 個別記事のコメントとトラックバックの分割表示(覚書)
  3. Plugin:Ultimate Tag Warrior 3 を wp.Vicuna で使う場合。(1)
  4. Plugin:WordPress Export 0.3 をいじってみる。
  5. Plugin:Paged Comments を使用した GuestBook for wp.Vicuna
2 Comments

2 Comments

Leave a Reply

Using Gravatars in the comments - get your own and be recognized!

XHTML: These are some of the tags you can use: <a href=""> <b> <blockquote> <code> <em> <i> <strike> <strong>