Limit comments displayed on basis of user_id

The pre_get_comments hook Note that the single post’s comments are fetched with get_comments(), within the comment_template() function. The get_comments() function is just a WP_Comment_Query object wrapper, so we can restrict the comment query with the pre_get_comments hook. Example #1 Here’s a simple user_id restriction example: ! is_admin() && add_action( ‘pre_get_comments’, function( \WP_Comment_Query $q ) { … Read more

Recent comments on author page?

This function calls all comments by an author and strips every comment to a max-length. Adjust the comment excerpt length when calling the function in your template like wpse19316_author_comments( 100 );. function wpse19316_author_comments( $length ) { $final_length = (int) $length; $author_comments = get_comments( array( ‘ID’ => $GLOBALS[‘authordata’]->ID ) ); foreach ( $author_comments as $comment ) … Read more

edit-comments.php comment_row_actions ajax problem

I resolved this issue by using the wp-ajax environment. Essentially, I created the callback function for the comment_row_actions filter which created the link pointing to admin-ajax.php in the admin directory with a query string. Then I created the add_action to run in the wp_ajax environment with a redirect back to the referring page. I couldn’t … Read more

Display the number of user comments

Got some idea from here. User’s comments have posted <?php function commentCount() { global $wpdb; $count = $wpdb->get_var(‘SELECT COUNT(comment_ID) FROM ‘ . $wpdb-comments. ‘ WHERE comment_author_email = “‘ . get_comment_author_email() . ‘”‘); echo $count . ‘ comments’; } commentCount(); ?> I don’t have any idea for comments that user got from their posts. Might be … Read more

Remove “says” from comments

Hope this is gonna help. Please try this snippet. Put it in your themes functions.php or you could it load it thorough a plugin or any other way- function the_dramatist_remove_says_from_comment( $translation, $text, $domain ) { //what text you want to have instead of ‘says’ in comments. For removing ‘says’ keep this blank $new_var=””; $translations = … Read more

How to add text to comment form #content textarea?

You can filter ‘comment_form_defaults’ to change the textarea. You get an array with the default fields as argument: add_filter( ‘comment_form_defaults’, ‘wpse_67503_textarea_insert’ ); function wpse_67503_textarea_insert( $fields ) { if ( /* your condition */ ) { $fields[‘comment_field’] = str_replace( ‘</textarea>’, ‘EXTRA CONTENT</textarea>’, $fields[‘comment_field’] ); } return $fields; }

How to show Disqus comments and pingbacks?

The plugin you mentioned is only a single function so it shouldn’t be too heavy on your setup. It uses the comments_template filter to inject the pingbacks/trackbacks list into your page. But the plugin is using an extra manual SQL query and the template is constructed by hand, so there’s a room for improvements/simplifications. A … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)