简体   繁体   中英

How to add PHP code in WordPress comment form?

I want to add a custom PHP code :

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

in the comment form section in the WordPress.

This is my comment form

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

There are a couple of useful action hooks , comment_form_top and comment_form :

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


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

There's also comment_form_before . It appears before <hr /><h3>Leave a Reply</h3> .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM