3

ワードプレスのテーマでリプレイ ボタンなどを表示するコメント リストの詳細日付を変更したい

<?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( __( '&larr; Older Comments', 'cusmagazines' ) ); ?></div>
        <div class="nav-next"><?php next_comments_link( __( 'Newer Comments &rarr;', '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( __( '&larr; Older Comments', 'cusmagazines' ) ); ?></div>
        <div class="nav-next"><?php next_comments_link( __( 'Newer Comments &rarr;', '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  } ?>

ここで、日付形式とコメントのラベルを変更する必要があります。どうすればそれを行うことができますか

4

2 に答える 2

0

日付形式を変更するだけです

get_comment_date('d.m.Y');

http://codex.wordpress.org/Function_Reference/get_comment_date http://codex.wordpress.org/Formatting_Date_and_Time

于 2013-08-21T07:42:05.283 に答える