Hot answers tagged

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 ...


2

You're adding the action on comment_form_before_fields in comment_form_logged_in_after. The latter is called only when the user is logged in, and the former is only called when the user is not logged in. You can add WordPress actions and filters at any time after WordPress is initialized. If you're adding the action in a plugin, add it on init or even when ...


1

This is that classic question, do you have 6 eggs or half a dozen, and frankly, it doesn't actually matter. It is however better to use get_comments_number() because the post object is retrieved from the $GLOBALS['post'] global which is set by the_post() inside the loop the post object is validated through WP_Post (through get_post()) the output from ...


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


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 ...


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

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

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

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.



Only top voted, non community-wiki answers of a minimum length are eligible