Tag Info

Hot answers tagged

6

You can try to modify it with the comment_form_defaults filter: /** * Modify the "must_log_in" string of the comment form. * * @see http://wordpress.stackexchange.com/a/170492/26350 */ add_filter( 'comment_form_defaults', function( $fields ) { $fields['must_log_in'] = sprintf( __( '<p class="must-log-in"> You must ...


5

You shouldn't copy that file, precisely because it is too bulky. About half of it is implementation of submission form, which was entirely replaced with comment_form() function around that time. So the answer why was it deprecated is roughly: Newer code is more compact Markup belongs in theme For better and more relevant comments.php example look at ...


5

Yes, it is possible, but it is a bit of a pain. Looking at the codex page, only arguments of note are number and offset. We need these two to create our paginated pages. First, we set the $paged parameter, which is the current page: $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; Then number of comments to display: $number = 3; ...


4

I wonder if you mean this kind of check: if( $comment->user_id > 0 ) { // Registered comment author } in your comment's template callback. This is determined in the the wp-comments-post.php file: $commentdata = compact('comment_post_ID', ..., 'user_ID' ); $comment_id = wp_new_comment( $commentdata ); but it's not obvious where the user_ID ...


4

The wp_list_comments() function uses the HTML comment list class Walker_Comment by default: A single comment is then displayed with the Walker_Comment::comment() method (#source). If the comment format is HTML5 then the Walker_Comment::html5_comment() is used instead (#source). The pingbacks are rendered with the Walker_Comment::ping() method (#source). ...


4

The comment_notification_text filter is in wp-includes/pluggable.php in the wp_notify_postauthor function. You can copy and paste the $notify_message stuff and edit out what you don't want. function wpd_comment_notification_text( $notify_message, $comment_id ){ // get the current comment and post data $comment = get_comment( $comment_id ); $post ...


4

There is definitely a performance advantage in keeping your comment spam to a minimum. If you have a lot of comments, the query time can get pretty out of control. To make it easier, you should install Akismet if you haven't already. Akismet will automatically detect spam comments and move them to WordPress spam section. You can then delete all the spam ...


3

There is no need for a plugin. The reason people get this confused is because posts can have comments enabled or disabled on an individual basis. There is no "global" option, because it's per post. So really, it just takes two main steps to disable comments in WordPress: Settings > Discussion. Turn off both "Allow link notifications from other blogs ...


3

You should consider hooking into the comment_class() and post_class() filters, if your theme supports it. Using the comment_class filter: We can add the following filter: /** * Add a custom comment class, based on a given comment author's user meta field. * * @see http://wordpress.stackexchange.com/a/170443/26350 */ add_filter( 'comment_class', ...


3

Try this: if( get_comment_author() == get_comment_author_link() ) echo get_avatar( $comment, $size='75' ); else echo '<a href="' . get_comment_author_url . '">' . get_avatar( $comment, $size='75' ) . '</a>';


3

Look at the function wp_delete_comment(). It fires an action before the comment is deleted: /** * Fires immediately before a comment is deleted from the database. * * @since 1.2.0 * * @param int $comment_id The comment ID. */ do_action( 'delete_comment', $comment_id ); … and one after deletion: /** * Fires immediately after a comment is deleted ...


3

From WordPress Version 4.1 (trac ticket #20446) it's now added to pass your own class as an argument of comment_form($args) using 'class_submit' array key: $args = array( 'class_submit' => 'btn btn-default' ); No need to do extra hard work. (Edited the Codex too) :)


3

There is no "safe" way to edit core files; if you do you will need to check and repeat the edition after every update. Not recommended at all. Instead of editing core files, you could use any of the actions and filters available. For example, pre_comment_on_post (example code not tested): add_action( 'pre_comment_on_post', function( $post_id ) { if( ...


3

is_page() is not available at that point try using global $post that way the post ID should be available for comparison. add_filter( 'preprocess_comment', 'wpb_preprocess_comment' ); function wpb_preprocess_comment($comment) { global $post; if ((strlen( $comment['comment_content'] ) < 60 ) && ($post->ID == 42)) { wp_die('Minimum allowed ...


3

It's not a bug (gasp!) really just not provided for. You have to add a filter to do this, eg add_filter( 'comments_clauses', function ( $pieces, $query ) { if ( empty( $query->query_vars['wpse_no_password'] ) ) return $pieces; global $wpdb; $pieces[ 'where' ] .= $wpdb->prepare( ' AND ' . $wpdb->posts . '.post_password = %s', '' ); ...


2

Add following code in your theme's functions.php. // To add extra column in column headers add_filter('manage_posts_columns', 'bs_event_table_head'); function bs_event_table_head( $defaults ) { $defaults['pending_comments'] = 'Pending Comments'; return $defaults; } // To add data in column for each post. add_action( 'manage_posts_custom_column', ...


2

Those options do not appear from the core but, they're are part of the Jetpack plugin. You should check with Jetpack files. Off-topic: I personally would prefer to disable these on Woocommerce pages. Hope this helps


2

Bulk edit the existing pages in the dashboard Posts or Pages view as noted here: Go to your All Posts page. Click on the checkbox in the header. Choose "Edit" under the bulk actions drop-down and then click Apply. The bulk edit area will appear. In the middle of the bulk edit area will be four drop-down menus. The second one is for comments. Change it to ...


2

You're re-inventing the wheel here ;-) The Problem You're bypassing WordPress with this approach, so that's explains the error message. Accessing any custom file, within your theme directory, will not load WordPress core automatically. Already available This is already supported by the WordPress core. You should check out comments_popup_link() and ...


2

This is possible using the comment_post action, and the GFAPI class which handles entries in WordPress. What you need to first is add using comment_form_default_fields a field which is a checkbox. function add_to_email_list_field($fields) { $fields['add-to-email'] = '<p class="comment-form-public"> <input id="addtoemail" ...


2

parent : Comments can be replies to other comments. Every comment has an ID number. When the comment is a reply, then it will have a "parent" which is the ID of the comment it is replying to. Putting a comment ID in here will get all the replies to that comment. post_parent : Posts can be children of other posts as well. This is how things like hierarchical ...


2

So after some time I done exactly what I wanted and I thought it would be nice to share. So in functions.php add function c_parent_comment_counter($pid,$uid){ global $wpdb; $query = "SELECT COUNT(comment_post_id) AS count FROM $wpdb->comments WHERE <code>comment_approved</code> = 1 AND <code>comment_post_ID</code> = $pid ...


2

When you are editing the post or page. You can disable comments from the "Discussion" box. By default this box is hidden. Show the Discussion meta box If you don't see a box labeled Discussion: Open the Screen Options by clicking the tab near the upper right-hand corner of the screen with the name Screen Options. Check the checkbox before Discussion. ...


2

This can be done, there is even a possibility to control this via the backend, just go to: → Settings → Discussion And there under: → Other comment settings You have the point: → Enable threaded (nested) comments | X | levels deep


2

After reading a bit on regex and preg, starting from a previous example of a similar problem and testing it I was able to answer my own question. I added this function to functions.php: <?php /** Plugin Name: WPSE (#167237) Redirect after comment */ add_filter('comment_post_redirect', 'redirect_after_comment'); function ...


2

wp_update_comment triggers the edit_comment action (source), you're creating an infinite loop.


2

You could try to count the number of unique comment author emails per post: /** * Number of unique comment author emails per post: * * @see http://wordpress.stackexchange.com/a/168606/26350 * @param int $pid * @return int */ function get_unique_commenters_by_post_id( $post_id ) { global $wpdb; $sql = "SELECT COUNT(1) as uc FROM ( ...


1

Had a similar problem, short blog entries found by google etc. showed the comment reply title instead of the blog entry content. This solution buffers the comment form html and replaces the <h3 id="reply-title"..> with another tag before printing it: function my_comment_form_before() { ob_start(); } add_action( 'comment_form_before', ...


1

Luckily, I was able to solve this. The problem was in #comments ul li p, so I deleted the margin and text-align properties from there, which were conflicting with the reply comment form, and modified other parts of the css file to achieve the same result. The solution might vary in other cases, but I hope this would help as a guide! This is the modified ...


1

The comments_open() function is used, both by core and typically themes to determine status for specific post. It has filter of same name for result, which you can use to manipulate it individually for the post. comment_form() won't actually output form if check is false and fire comment_form_comments_closed action in such case. Native WP themes, shipped ...



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