New answers tagged

2

Please place below code in your theme's functions.php file and it will wrap the submit button inside div: // define the comment_form_submit_button callback function filter_comment_form_submit_button( $submit_button, $args ) { // make filter magic happen here... $submit_before = '<div class="form-group">'; $submit_after = '</div>'; ...


3

We can use comment_form function's submit_button parameter to change submit button HTML. Default HTML for submit_button is <input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" /> You can change your code like this. $comments_args = array( .... 'submit_button' => '<div class="form-group"> <input ...


1

Im not aware of any hook that could change only comment notification recipient.. You would probably need to overwrite some kind of core function but here's a small workaround you could use: 1. Disable the email feature from WordPress comments settings (unless you want to get notified too) 2. Send it manually using comment_post action hook, just add this ...


0

Now what if you have to add/remove fields from default contact form to change the feel of your comment box? I am eliminating website field from default comment box by playing with ‘fields’ argument:in comments.php <?php $comment_args = array('title_reply' => 'Got Something To Say:', 'fields' => apply_filters('comment_form_default_fields', ...


0

I believe you can hook your new function to comment_template() like this: add_action('comments_template', 'my_function') or function hide_my_comment_template() { return null; } add_action('comments_template', 'hide_my_comment_template')


1

Comments are kind of "limited" in WordPress. You have three different types for them as get_comment_type() shows nicely and you can not extend that list. So, adding meta values to your comments is the easiest, and probably "most standard" way, to be able to distinguish different "types" of comments. Handling the comment in- and output stays basically the ...


0

User switching plugin might ease the the pain while switching users.


1

Comments automatically use credentials of logged in user. You have two options: Log out of your account and leave a comment like a regular user. Log in into different account via native means or use a plugin that allows you to switch between accounts.


0

The 'problem' with the @ialocin answer is that there is no reply link and therfore any notification plugins that rely on replies won't work. A tricky workaround is to use css (which is dependent on your theme's design) to counteract/remove the threaded indentation, and then, apply this code to allow many more depths of a thread. This way you can still have ...


1

If you mean the comments in comments_template() then you can use the new comments_template_query_args filter that was added with ticket #34442 in version 4.5: /** * Filters the arguments used to query comments in comments_template(). * * @since 4.5.0 * * @see WP_Comment_Query::__construct() * * @param array $comment_args { * Array of ...


1

The comment_text filter passes the comment as one of its params: echo apply_filters( 'comment_text', $comment_text, $comment, $args ); So you don't need to call get_comment_ID(), you can just access the ID from the $comment object. Change: add_filter( 'comment_text', 'modify_comment'); to: add_filter( 'comment_text', 'modify_comment', 0, 3 ); And ...


1

For anyone else trying to find this: This can be done using the $parent parameter of get_comments. Here is the code assuming $parent_comment_id is the id of the parent comment. $childcomments = get_comments(array( 'post_id' => get_the_ID(), 'status' => 'approve', 'order' => 'DESC', 'parent' => ...


1

Never edit the WordPress core files. Instead you should hook into the pre_comment_content, which is where the comment text from the textarea is being sanitized, before it's inserted into the database. In the example below preg_replace is used to sanitize the comment text submitted. You should modify the function to fit your needs. function ...


0

Just more exmple : function allow_tags_content() { global $allowedposttags, $allowedtags; $allowedposttags['div']['data-hello'] = true; $allowedtags['div']['data-hello'] = true; $allowedposttags['div']['data-world'] = true; $allowedtags['div']['data-world'] = true; } add_action('init','allow_tags_content');


0

Just with JS there is no way, because the visitor can reload the page or close window and reopen and reset everything. You can create a table in your wordpress database where the user's name will be saved with 0 (if no comments was done) and the id of the post (if commented). So in one more column, you create the replies number, starting with 0 and go ...


2

I've often thought this would make a good feature, though I've never seen a plugin for it. I think the term "comment" is probably throwing off your search. I wouldn't think that this would be stored as a comment internally, but rather as metadata for the post. I did a search for plugins using the term "revision description" instead of revision comment, and I ...


0

I just tested your code as-is on my site (I manually added comment meta values to 3 comments) and it worked fine. The only thing I did was comment out 'post_type' => 'fod_articles', since I don't have that post type. Is it supposed to be fod_articles or food_articles? Edit: I tested again, this time with a custom post type, and it worked after making ...


0

Can you access your site via FTP or through your host control panels file manager? If you can, check to see if there is any code within wp-comments-post.php in the root of your site. If it is empty, paste this inside: <?php /** * Handles Comment Post to WordPress and prevents duplicate comment posting. * * @package WordPress */ if ( 'POST' != ...


0

According to Function Reference for wp_list_comments, you can set the arg Echo to false to return the list. I imagine the default walker will not echo the code if this is set to false. wp_list_comments(array('reverse_top_level' => false, 'echo' => false), $comments);


0

Here you go: http://www.contradodigital.com/2016/04/06/post-comments-wordpress-rest-api-version-2/ Just had to do this myself, the documentation in the official WordPress API v2 isn't the best at the minute.


-1

Thanks! Found the problem: I activated comments in settings, but there´s a checkbox for each post in the post edit screen. Without that activated, it won´t even throw an error.


1

Just as @Jevuska mentioned, you can use the $post_id as an argument here, in fact, you can also use a ton of optional $args as well <?php comment_form( $args, $post_id ); ?> You can find the information in the Codex here: https://codex.wordpress.org/Function_Reference/comment_form



Top 50 recent answers are included