如何在WordPress评论表单中添加PHP代码?

时间:2014-05-20 13:04:14

标签: php wordpress

我想添加自定义PHP代码:

<?php if(function_exists('the_ratings')) { the_ratings(); } ?> 

在WordPress的评论表单部分。

这是我的评论表格

<?php comment_form(array('label_submit' => 'Post Review')); ?>

1 个答案:

答案 0 :(得分:3)

有几个useful action hookscomment_form_topcomment_form

add_action( 'comment_form_top', function(){
    echo '<h1>Top</h1>';
});


add_action( 'comment_form', function(){
    echo '<h1>Bottom</h1>';
});

还有comment_form_before。它出现在<hr /><h3>Leave a Reply</h3>之前。