Thomas Anderson
Thomas Anderson

Reputation: 13

Wordpress remove comment_form( 'cancel_reply_link' )?

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.

https://i.sstatic.net/Gsjdi.png

Upvotes: 0

Views: 2405

Answers (2)

Rych
Rych

Reputation: 113

If you want to remove the cancel link you need to use wordpress built in __return_false function for returning false value for filters like this:

add_filter( 'cancel_comment_reply_link', '__return_false' );

This has already been answered here.

The above function resides in wp-includes/functions.php:

function __return_false() {
    return false;
}

There are more similar functions returning common values for filters like: __return_true or __return_empty_string in wp-includes/functions.php

Upvotes: 0

O. Jones
O. Jones

Reputation: 108686

You have a couple of choices here. One is to use css to conceal that element from your users.

h3.comment-reply-title { display: none) 

The other choice might be to use the 'cancel_comment_reply_link' filter to edit the html.

https://core.trac.wordpress.org/browser/tags/4.1.1/src/wp-includes/comment-template.php#L1549

Upvotes: 1

Related Questions