admin管理员组文章数量:1122846
Anyone know how can I change the comment reply text in wordpress to only reflect on specific pages only and not the whole site?
For example the default text site-wide is “Leave a Reply”. But for some specific pages only, I want the text to read “Leave a Review”.
Is there some code I could use in the comments.php file that would make this work?
Anyone know how can I change the comment reply text in wordpress to only reflect on specific pages only and not the whole site?
For example the default text site-wide is “Leave a Reply”. But for some specific pages only, I want the text to read “Leave a Review”.
Is there some code I could use in the comments.php file that would make this work?
Share Improve this question asked May 8, 2019 at 6:33 dudesonwilldudesonwill 212 bronze badges2 Answers
Reset to default 2Code is not tested. But theoretically it should work:
add_filter('comment_form_defaults', 'wpse337366_comment_form_modification');
function wpse337366_comment_form_modification($defaults)
{
// put your condition here
if( is_page('my-page') || is_singular('my_post_type') )
{
$defaults['title_reply'] = __('Leave a Review');
}
return $defaults;
}
You can place the code in a plugin or your theme's functions.php
.
The code will filter the default texts passed to the comment_form()
.
Reference
comment_form()
- WordPress Developer Resources
In your page template, when you call comments template like this, <?php comment_form(); ?>
it'll load default theme template. In the page template you need to change comment title, simply call comments template like below,
<?php
comment_form(array(
'title_reply' => __( 'Leave a Review' ),
));?>
本文标签: How can change wordpress comment reply text for specific pages only
版权声明:本文标题:How can change wordpress comment reply text for specific pages only? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736284656a1927295.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论