• Resolved Cory.Nickerson

    (@corynickerson)


    Customizing my comment templates and I’m working with the comment_form function.

    http://codex.wordpress.org/Function_Reference/comment_form

    It seems easy enough to remove some things such as the text below the form that says “you may use these tags and attributes” and other things by overwritting the defaults with blank values. However it doesn’t let you remove the cancel_reply_link from the template as removing its value from the array still makes it display the default.

    <?php
        comment_form(
            array(
                'comment_notes_after'   => '',
                'title_reply'           => '',
                'comment_field'         => '<textarea id="comment" name="comment" aria-required="true" placeholder="Leave a comment..."></textarea>',
                'logged_in_as'          => '',
                'cancel_reply_link'     => ''
            )
        );
    ?>

    As you can see the cancel_reply_link is left empty, but it will still output the following HTML before my comment textarea.

    <h3 id="reply-title" class="comment-reply-title">
        <small>
            <a rel="nofollow" id="cancel-comment-reply-link" href="/websites/wordpress/post-6/comment-page-1/#respond">Click here to cancel reply.</a>
        </small>
    </h3>

    How can i remove this h3 and its content?

    The reason I want it removed is so I can simply add a “cancel” button next to the “submit” button below the textarea when people are replying to others comments.

    Thanks.

    View post on imgur.com

Viewing 7 replies - 1 through 7 (of 7 total)
  • I was just searching for the answer to the very same problem. I want to move it under the submit. I haven’t had any luck, but I’ll let you know if I do.

    Frustrating!

    Thread Starter Cory.Nickerson

    (@corynickerson)

    I think I’m just going to make a new function rewriting the default function for this. Will post it if I do.

    Thread Starter Cory.Nickerson

    (@corynickerson)

    Okay so if you are using the <?php comment_form(); ?> function in your template to display the comment form and adjusting the variables within the array to change things, just replace it with this.

    <form action="<?php echo get_bloginfo( 'url' ); ?>/wp-comments-post.php" method="post" id="commentform" class="comment-form">
    	<textarea id="comment" name="comment" aria-required="true" placeholder="Leave a comment..."></textarea>
    	<p class="form-submit">
    		<input name="submit" type="submit" id="submit" class="submit" value="Post Comment" />
    		<input type="hidden" name="comment_post_ID" value="<?php echo get_the_ID(); ?>" id="comment_post_ID" />
    		<input type="hidden" name="comment_parent" id="comment_parent" value="<?php if ( isset( $_GET['replytocom'] ) ) { echo $_GET['replytocom']; } else { echo 0; } ?>" />
    	</p>
    	<?php wp_comment_form_unfiltered_html_nonce(); ?>
    </form>
    Thread Starter Cory.Nickerson

    (@corynickerson)

    test. its not letting me past code.

    Your posts were getting caught in the spam filter – I just fished them out.

    Thread Starter Cory.Nickerson

    (@corynickerson)

    What was I doing wrong? for reference.

    Thread Starter Cory.Nickerson

    (@corynickerson)

    Edit: this is working good now.

    <?php
    	comment_form(
    		array(
    			'comment_notes_after'	=> '',
    			'title_reply'				=> '',
    			'comment_field'			=> '<textarea id="comment" name="comment" aria-required="true" placeholder="Leave a comment..."></textarea>',
    			'logged_in_as'				=> '',
    			'cancel_reply_link'		=> ''
    		)
    	);
    ?>

    I replaced this line in comments.php with the following:

    <div id="respond" class="comment-respond">
    	<form action="<?php echo get_bloginfo( 'url' ); ?>/wp-comments-post.php" method="post" id="commentform" class="comment-form">
    		<textarea id="comment" name="comment" aria-required="true" placeholder="Leave a comment..."></textarea>
    		<p class="form-submit">
    			<input name="submit" type="submit" id="submit" class="submit" value="Post Comment" />
    			<?php if ( $_GET['replytocom'] != 0 ) : ?>
    				<a rel="nofollow" id="cancel-comment-reply-link" class="button" href="/websites/wordpress/post-6/#respond">Cancel Reply</a>
    			<?php else : ?>
    				<a rel="nofollow" id="cancel-comment-reply-link" class="button" href="/websites/wordpress/post-6/#respond" style="display: none;">Cancel Reply</a>
    			<?php endif; ?>
    			<input type="hidden" name="comment_post_ID" value="<?php echo get_the_ID(); ?>" id="comment_post_ID" />
    			<input type="hidden" name="comment_parent" id="comment_parent" value="<?php if ( isset( $_GET['replytocom'] ) ) { echo $_GET['replytocom']; } else { echo 0; } ?>" />
    		</p>
    		<?php wp_comment_form_unfiltered_html_nonce(); ?>
    	</form>
    </div>

    Works great

    Screenshot of how it looks.

    View post on imgur.com

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘WordPress remove comment_form( 'cancel_reply_link' )?’ is closed to new replies.