我想在我的wordpress主题中修改我的评论列表详细日期显示重播按钮等我看到这个代码并且我使用它但我需要修改日期格式和标签和标题等我使用此代码
<?php /*----------------------------------- Template for Comments ---------------------------------------*/ ?>
<div id="comments">
<?php if ( post_password_required() ) : ?>
<p class="text-error"><?php _e( 'This post is password protected. Enter the password to view any comments.', 'cusmagazines' ); ?></p>
</div>
<?php
return;
endif;
?>
<?php if ( have_comments() ) : ?>
<h2 id="comments-title">
<?php
printf( _n( 'One Comment', '%1$s Comments', get_comments_number(), 'cusmagazines' ), number_format_i18n( get_comments_number() ) );
?>
<a class="goto goto-respond" href="#respond" title="Add Your Comment">( Add Comment )</a>
</h2>
<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : ?>
<div id="comment-nav-above">
<h1 class="assistive-text"><?php _e( 'Comment navigation', 'cusmagazines' ); ?></h1>
<div class="nav-previous"><?php previous_comments_link( __( '← Older Comments', 'cusmagazines' ) ); ?></div>
<div class="nav-next"><?php next_comments_link( __( 'Newer Comments →', 'cusmagazines' ) ); ?></div>
</div>
<?php endif; ?>
<div class="commentlist">
<?php
$args = array(
'walker' => null,
'max_depth' => 3,
'style' => 'div',
'callback' => 'custhemes_comment',
'end-callback' => null,
'type' => 'all',
'page' => null,
'per_page' => null,
'avatar_size' => 45,
'reverse_top_level' => null,
'reverse_children' => null );
wp_list_comments($args);
?>
</div>
<?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : ?>
<div id="comment-nav-below">
<h1 class="assistive-text"><?php _e( 'Comment navigation', 'cusmagazines' ); ?></h1>
<div class="nav-previous"><?php previous_comments_link( __( '← Older Comments', 'cusmagazines' ) ); ?></div>
<div class="nav-next"><?php next_comments_link( __( 'Newer Comments →', 'cusmagazines' ) ); ?></div>
</div>
<?php endif; ?>
<?php
elseif ( ! comments_open() && ! is_page() && post_type_supports( get_post_type(), 'comments' ) ) :
?>
<p class="nocomments"><?php _e( 'Comments are closed.', 'cusmagazines' ); ?></p>
<?php endif; ?>
我将此代码添加到function.php
<?php function custhemes_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
extract($args, EXTR_SKIP);
if ( 'div' == $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
<?php if ( 'div' != $args['style'] ) : ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-body">
<?php endif; ?>
<div class="comment-author vcard">
<?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['avatar_size'] ); ?>
</div>
<?php if ($comment->comment_approved == '0') : ?>
<em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.') ?></em>
<br />
<?php endif; ?>
<div class="comment-meta commentmetadata">
<?php printf(__('<span class="author-name">%s</span>'), get_comment_author_link()); ?>
<a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>">
<?php printf( __('%1$s - %2$s'), get_comment_date('d.m.Y'), get_comment_time()); ?>
</a>
<?php edit_comment_link(__('(Edit)'),' ','' );
?>
</div>
<div class="comment-text"><?php comment_text(); ?></div>
<div class="reply">
<?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
</div>
<?php endif; ?>
<?php } ?>
现在我需要修改日期格式和评论的标签 我怎么能这样做
答案 0 :(得分:2)
使用此过滤器人。
add_filter( 'get_comment_date', 'wpse_comment_date_18350375' );
function wpse_comment_date_18350375( $date ) {
$date = date("m.d.y");
return $date;
}
答案 1 :(得分:0)
只需修改
中的日期格式即可get_comment_date('d.m.Y');
http://codex.wordpress.org/Function_Reference/get_comment_date http://codex.wordpress.org/Formatting_Date_and_Time