自定义我的评论模板,我正在使用comment_form函数。
http://codex.wordpress.org/Function_Reference/comment_form
删除一些内容似乎很容易,比如表单下面的文本“您可以使用这些标记和属性”,以及通过用空白值覆盖默认值来删除其他内容。然而,它不允许您从模板中删除`cancel_reply_link‘,因为从数组中删除它的值仍然会使其显示默认值。
<?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' => ''
)
);
?>正如您所看到的,cancel_reply_link是空的,但它仍然会在我的注释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>如何删除此h3及其内容?
我想要删除它的原因是,当人们回复其他人的评论时,我可以简单地在textarea下面的“提交”按钮旁边添加一个“取消”按钮。
谢谢。
http://i.stack.imgur.com/Gsjdi.png
发布于 2015-02-22 03:24:29
这里有几个选择。一种是使用css向用户隐藏该元素。
h3.comment-reply-title { display: none) 另一种选择可能是使用'cancel_comment_reply_link'过滤器来编辑html。
https://core.trac.wordpress.org/browser/tags/4.1.1/src/wp-includes/comment-template.php#L1549
发布于 2018-03-20 06:45:52
如果你想删除取消链接,你需要使用wordpress内置的__return_false函数来为过滤器返回False值,如下所示:
add_filter( 'cancel_comment_reply_link', '__return_false' );here已经回答了这个问题。
上面的函数位于wp-includes/functions.php中:
function __return_false() {
return false;
}还有更多类似的函数返回过滤器的通用值,比如: wp-includes/functions.php中的__return_true或__return_empty_string
https://stackoverflow.com/questions/28650081
复制相似问题