• vespino

    (@vespino)


    I have the following code which I’m using for displaying comments:

    <?php
    if ( post_password_required() ) {
    	return;
    }
    
    function format_comment($comment, $args, $depth) {
    	?>
        <div class="row">
            <div class="col-xs-12 col-sm-3 col-lg-2"> 
                <div class="author">
                    <span><strong><?php echo $comment->comment_author; ?></strong><br/>20 november 2016</span>
                    <a class="hidden-sm hidden-md hidden-lg" href=""><?php _e('> Reageer', 'e52'); ?></a>
                </div>
            </div>
            <div class="col-xs-12 col-sm-9 col-lg-10"> 
                <div class="message">
                    <p><?php echo $comment->comment_content; ?></p>
                    <a class="hidden-xs" href=""><?php _e('> Reageer', 'e52'); ?></a>
                </div>
            </div>
        </div>
        <?php
    }
    ?>
    <div id="comments" class="comments-area">
    	<?php if ( have_comments() ) : ?>
    		<?php wp_list_comments('type=comment&callback=format_comment'); ?>
    	<?php endif; ?>
    </div>

    I would like to be able to use the reply function and implemented the following function:

    comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth'])))

    This results in a link: /?replytocom=1#respond

    Problem is when clicking this link I would expect to be focused on the comments form and start replying but all it does is refresh the page. Do I have to activate replies in some way

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator bcworkz

    (@bcworkz)

    Your comments form has to have id="respond" as an attribute for that link to work as intended.

    Thread Starter vespino

    (@vespino)

    The following HTML was created by the comment_form function:

    <div id=”respond” class=”comment-respond”>
    <h3 id=”reply-title” class=”comment-reply-title”> <small>Reactie annuleren</small></h3>
    <form action=”/wp/wp-comments-post.php” method=”post” id=”commentform” class=”comment-form”>
    <p class=”comment-form-comment”>
    <textarea id=”comment” name=”comment” aria-required=”true”></textarea>
    </p>
    <p class=”form-submit”>
    <input name=”submit” type=”submit” id=”submit” class=”submit” value=”Send” />
    <input type=’hidden’ name=’comment_post_ID’ value=’83’ id=’comment_post_ID’ />
    <input type=’hidden’ name=’comment_parent’ id=’comment_parent’ value=’0′ />
    </p>
    <input type=”hidden” id=”_wp_unfiltered_html_comment_disabled” name=”_wp_unfiltered_html_comment_disabled” value=”95b5f1374c” />
    <script>(function(){if(window===window.parent){document.getElementById(‘_wp_unfiltered_html_comment_disabled’).name=’_wp_unfiltered_html_comment’;}})();</script>
    </form>
    </div>

    $comments_args = array(
        // change the title of send button 
        'label_submit'=>'Send',
        // change the title of the reply section
        'title_reply'=>_e('<h4>Reageren</h4>', 'e52'),
        // remove "Text or HTML to be displayed after the set of comment fields"
        'comment_notes_after' => '',
        // redefine your own textarea (the comment body)
        'comment_field' => '<p class="comment-form-comment"><textarea id="comment" name="comment" aria-required="true"></textarea></p>',
    );
    
    comment_form($comments_args);

    What exactly should I change according to you?

    Moderator bcworkz

    (@bcworkz)

    You already have an id=”respond” in the first div, which should be close enough. Thus what I thought was the problem is wrong. I’m not sure what would prevent the link from working properly. If you can, please provide a full, functional link to a page that demonstrates the problem.

    Thread Starter vespino

    (@vespino)

    Thread Starter vespino

    (@vespino)

    Just fixed it by simply adding the following to my first div.row: id=”comment-<?php comment_ID(); ?>”

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Comments template’ is closed to new replies.