【问题标题】:Wordpress wp_enqueue_script( 'comment-reply' ) for custom theme用于自定义主题的 Wordpress wp_enqueue_script('comment-reply')
【发布时间】:2012-06-12 06:09:54
【问题描述】:

我一直在关注这个tutorial,但我无法使用wp_enqueue_script( 'comment-reply' ); php 函数让我的回复按预期工作。

我删除了我认为与我希望完成的任务无关的代码。

预期输出(取自 211 1.3 减去样式表


(来源:iforce.co.nz

实际输出(取自我的主题减去样式表


(来源:iforce.co.nz

我如何才能根据此tutorial 完成预期输出以获得高级评论?我应该用我的functions.php和single.php做什么来完成它?

【问题讨论】:

    标签: php html wordpress


    【解决方案1】:

    解决方案实际上非常简单......在阅读了一些 javascript 的 wordpress 代码之后。我发现问题在于每个评论块是如何创建的。

    基于function.php中的这个函数

    //this function will be called in the next section
    function advanced_comment($comment, $args, $depth) {
    $GLOBALS['comment'] = $comment; 
    $PostAuthor = false;
    if($comment->comment_author_email == get_the_author_email()) {
    $PostAuthor = true;}
    elseif($comment->comment_author_email == 'mordauk@gmail.com') {
    $PostAuthor = true;} ?>
    <li <?php if($PostAuthor) {echo "class='authorcomment' ";} ?>
    <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
    <div class="comment-author vcard">
    <?php echo get_avatar($comment, $size='48',$default='<path_to_url>' ); ?>
    <div class="comment-meta"<a href="<?php the_author_meta( 'user_url'); ?>"><?php printf(__('%s'), get_comment_author_link()) ?></a></div>
    <small><?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?><?php edit_comment_link(__('(Edit)'),'  ','') ?></small>
    </div>
    <?php if ($comment->comment_approved == '0') : ?>
    <div id="moderation"><?php _e('Your comment is awaiting moderation.') ?></div>
              <?php endif; ?><br />
            <div class="comment-text">  
              <?php comment_text() ?>
            </div>
              <div class="reply">
                 <?php comment_reply_link(array_merge($args, array('depth' => $depth, 'max_depth' => $args['max_depth'])), $comment->comment_ID) ?>
                 <?php delete_comment_link(get_comment_ID()); ?>
              </div>
      <div class="clear"></div>
          <?php } ?>
    

    我发现错误在于

    <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
    

    通过简单地删除 id 中的“li-”,使其形成 id="comment-"

    回复表单现在继续回复。

    【讨论】:

    • 就是这样:通过简单地删除 id 中的“li-”,使其形成 id="comment-"
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-05
    • 2014-06-02
    • 1970-01-01
    • 2019-04-27
    • 1970-01-01
    • 2012-01-15
    相关资源
    最近更新 更多