如何修改wordpress列表注释中的日期格式 [英] how to modify date format in wordpress list comments

查看:164
本文介绍了如何修改wordpress列表注释中的日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想修改我的评论列表详细日期显示重播按钮等在我的wordpress主题我看到这个代码,我使用它,但我需要修改日期格式和标签和标题等我使用这个代码



I want to modify my comments list detail date showing replay button and etc in my wordpress theme i saw this code and i use it but i need to modify the date format and the lable and titles and etc i use this code

<?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

and i add this code to 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  } ?>

现在我需要修改日期格式和注释的标签

now i need to modify date format and the lable of the comments how can i do that

 解决方案 

推荐答案

get_comment_date('dmY');

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

这篇关于如何修改wordpress列表注释中的日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆