Custom Default Avatar

/** * IMPORTANT: After activating this snippet you have to change the default avatar option in Settings » Discussion to “Custom Avatar” as defined below. */ add_filter( ‘avatar_defaults’, function( $avatar_defaults ) { $new_avatar_url = ‘https://wpcode.com/wp-content/uploads/2024/09/wpcode-avatar.png’; // Replace this with your…Continue reading

Auto-Collapse Long Comments

add_filter( ‘comment_text’, function( $comment_content ) { $max_length = 100; // Set the maximum length of the comment to display without collapsing if ( strlen( $comment_content ) > $max_length ) { $short_content = substr( $comment_content, 0, $max_length ) . ‘…’; $full_content…Continue reading

Limit Comments & Display Character Count

if ( ! class_exists( ‘WPCode_Comment_Limit_Counter’ ) ) { class WPCode_Comment_Limit_Counter { // Update this value to change the maximum number of characters allowed in a comment. protected $comment_max_length = 1000; // Update this value to change the minimum number of…Continue reading

Disable Comment Form Website URL

add_filter( ‘comment_form_default_fields’, function ($fields) { if ( isset( $fields[‘url’] ) ) { unset( $fields[‘url’] ); } if ( isset( $fields[‘cookies’] ) ) { // Remove the website mention from the cookies checkbox label. $fields[‘cookies’] = str_replace(‘name, email, and website’, ‘name…Continue reading

Completely Disable Comments

add_action(‘admin_init’, function () { // Redirect any user trying to access comments page global $pagenow; if ($pagenow === ‘edit-comments.php’) { wp_safe_redirect(admin_url()); exit; } // Remove comments metabox from dashboard remove_meta_box(‘dashboard_recent_comments’, ‘dashboard’, ‘normal’); // Disable support for comments and trackbacks in…Continue reading