Wordpress wp_enqueue_script('comment-reply')为自定义主题 [英] Wordpress wp_enqueue_script( 'comment-reply' ) for custom theme

查看:111
本文介绍了Wordpress wp_enqueue_script('comment-reply')为自定义主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在关注这个教程我无法设法让我的回复像 wp_enqueue_script('comment-reply'); php函数一样符合预期。





我认为这与我希望完成的事情无关。



预期输出(采用二十一十一个1.3减号样式表) b>



预期输出http ://iforce.co.nz/i/n3cvsots.tjn.png



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



实际输出http://iforce.co.nz/i/w3x4u4q0.3w4.png



如何完成期望的输出基于此教程进行高级评论?我应该怎么做我的functions.php和single.php来完成它?

解决方案

解决方案其实很简单...在阅读javascript的wordpress代码之后。我发现问题在于如何创建每个注释块。



基于function.php中的此函数



<$
函数advanced_comment($ comment,$ args,$ depth){
$ GLOBALS ['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){echoclass ='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(__('(编辑)'),'','')?>< / small>
< / div>
<?php if($ comment-> comment_approved =='0'):?>
< div id =moderation><?php _e('您的评论正在等待审核。')?>< / 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 -



回复表单现在回复。


I've been following this tutorial and I can't manage to get my Reply working as intended with the wp_enqueue_script( 'comment-reply' ); php function.

I've removed code which I think is irrelevant for what I wish to accomplish.

Expected Output (Taken from Twenty Eleven 1.3 Minus stylesheets)

Expected output http://iforce.co.nz/i/n3cvsots.tjn.png

Actual Output (Taken from my theme Minus stylesheets)

Actual output http://iforce.co.nz/i/w3x4u4q0.3w4.png

How can I accomplish the Expected Output based off this tutorial for Advanced Comments? and what should I be doing with my functions.php and single.php to accomplish it?

解决方案

The solution is actually pretty simple... after a little of reading the wordpress code for the javascript. I found the problem was in how each comment block was created.

based off this function in 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 } ?>

I found the error was with

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

By simply removing the "li-" in the id so it forms id="comment-"

The reply form now moves on reply.

这篇关于Wordpress wp_enqueue_script('comment-reply')为自定义主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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