简体   繁体   English

如何在评论标题中插入wordpress帖子值?

[英]How to insert a wordpress post value into the comments title?

I'm trying to insert the wordpress post value $offer_title into the comments box title. 我正在尝试将wordpress post值$ offer_title插入到评论框标题中。 The title currently reads as 'Leave Your Review' but I want it to show the $offer_title value before the 'review' part like "Leave Your XYZ Review". 标题目前显示为“保留您的评论”,但我希望它在“评论”部分之前显示$ offer_title值,例如“保留您的XYZ评论”。

This is the current code for the comments section... 这是评论部分的当前代码......

$custom_comment_field = '<textarea id="comment" name="comment" cols="30" rows="10" aria-required="true"></textarea>';
$commenter = wp_get_current_commenter();
            comment_form(array(
                'comment_field'         => $custom_comment_field,
                'comment_notes_after'   => '',
                'logged_in_as'          => '',
                'comment_notes_before'  => '',
                'title_reply'           => __('Leave a Review', 'rehub_framework'),
                'cancel_reply_link'     => __('Cancel reply', 'rehub_framework'),
                'label_submit'          => __('Submit', 'rehub_framework'),
                'fields' => apply_filters( 'comment_form_default_fields', array(

                    'author' =>
                        '<div class="usr_re"><input id="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) .'" name="author" placeholder="'.__('Name', 'rehub_framework').'"></div>',

                    'email' =>
                        '<div class="email_re"><input id="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) .'" name="email" placeholder="'.__('E-mail', 'rehub_framework').'"></div>',

                    'url' =>
                        '<div class="site_re end"><input id="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) .'" name="url" placeholder="'.__('Website', 'rehub_framework').'"></div><div class="clearfix"></div>',
                )
              ),
            ));

Any tips would be much appreciated. 任何提示将非常感激。 Thank you :-) 谢谢 :-)

Replace the line which states: 替换说明的行:

'title_reply'           => __('Leave a Review', 'rehub_framework'),

with

'title_reply'           => 'Leave your '. $offer_title .' Review',

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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