1

I'm developing a new theme and plugins for it. Unfortunately, the comment reply link is broken. Instead of moving the comment reply textarea, the page is reloaded by adding e.g. ?replytocom=2#respond to the URL (corresponding to the value of the href attribute).

Here's a link to see what I mean: ... (No longer necessary to view link)

Thanks in advance for your help!

Best joschi81

EDIT: I found out that it's caused by my "dirty" hack to modify the #reply-title. Which I do like this: functions.php.

// add variable to change comment form title
function add_comment_title_variable($content) {
    $output = $content;
    if(is_single() && comments_open()) $output .='<script type="text/javascript"> var commentFormTitle = "'.__('Leave a comment','theme-text-domain').'"; </script>';
    return $output;
}
add_filter('the_content','add_comment_title_variable');

Main JS file of my theme:

$(document).ready(function(){
    // [...]
    if(typeof(commentFormTitle) != 'undefined') $('#reply-title').html(commentFormTitle);
});

So, any hints how I can "individualize" the translation/textoutput of the comment form title without such dirty hack?

I kept it within the same question as other people who have the same problem with the comment reply link might be causing it the same way.

Thanks joschi81

1

It is because you need to enqueue comment-reply.js which is required for the jQuery effect.

Place the following in your header.php file within your head tag:

if ( is_singular() && get_option( 'thread_comments' ) )
    wp_enqueue_script( 'comment-reply' );
  • Thanks for your reply. The code you mentioned is included in my functions.php - my theme is built upon an "empty" theme from www.underscores.me. But I found out what the problem really is. See edit in my question. – joschi81 Jun 4 '15 at 4:26
  • @joschi81 No problem, make sure to accept your own answer once it's possible. – Christine Cooper Jun 4 '15 at 11:00
1

Solved! I found the optimal solution here: https://wordpress.org/support/topic/how-to-change-wording-of-leave-a-reply#post-1881213 I added my theme's textdomain like so:

// individual comment form title
function comment_reform ($arg) {
    $arg['title_reply'] = __('Leave a comment','theme-textdomain');
    return $arg;
}
add_filter('comment_form_defaults','comment_reform');

Sorry, the comment_form() function was still a bit unclear for me, especially when it comes to filter the default args.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.