Here is function that return you the comment author initials by the comment id
function get_comment_author_initials($comment_id) {
$author = get_comment_author($comment_id);
$words = explode(" ", $author);
$initials = null;
foreach ($words as $w) {
$split = mb_str_split($w); // to cover unicode char
$initials .= $split[0];
}
return $initials;
}
function mb_str_split( $string ) {
return preg_split('/(?<!^)(?!$)/u', $string );
}
And you can use it in your code like this
<div class="class2">
<?php echo get_comment_author_initials($comment->comment_ID); ?>
</div>
Related Posts:
- Change comments form title on a page by page basis
- How do I create comment-reply-button using element not
- Replace comment avatars and links at the same time
- Adding ads code between comments
- How do I fetch all comments per post via WP REST API?
- comments_number display outside specified span
- “comments.php” not available after edit in WP administration
- Ajax load more button for comments wordpress
- Limit 1 global comment per minute
- Create Page To Count Comments For Each Post In WordPress Site
- wp-comments-post.php file returns a blank page
- php function to display commenter username or login
- Alter required message using comment form api
- WordPress comment submit button substitutes/options
- Does anyone know all parameters of get_comments()
- Send a mail to specific address in a custom field when a new comment is made on a specific post
- get_comments_number() returns 0
- comment_post (if comment is approved OR $comment_approved === 1) not working?
- Show all people who commented on all posts by an author
- Display the list of user’s comments + the post title + date
- How do I make comment-reply-button with that takes to comment reply form on click
- How to get the rating value of each comment
- Trouble figuring out how to get my button to submit comment
- Cleaning up WordPress to improve performance?
- List of all theme customizer control types?
- Modify previous and next text from pagination links
- How can I modify the permalink via a filter?
- wp_set_object_terms and arrays
- Shortcode putting html such as
- How to get the original price of the product in woocommerce?
- Calling a method from functions.php on a click of a button
- How to redirect users to custom lostpassword page?
- How to use WordPress (PHP) functions in AngularJS partials files?
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- How to change featured content to a different tag in WordPress Twenty Fourteen?
- Can I write ‘RewriteCond’ using ‘functions.php’?
- How to add 2 posts under another post? Formatting should be intact
- WordPress menu deletes when trying to add a hook
- Overriding a theme redux file in child theme
- Validate a users email address when using gmail to register
- Get widget settings function?
- Output a WooCommerce product custom field in WooCommerce using get_post_meta()
- enqueue multiple Google fonts with multiple weights and styles (italic)
- How to check If Oembed is empty or not
- Making Quote Plugin more efficient
- What is the fastest way to load PHP functions that are only used in one theme template?
- Adding tawk.to code just before body tag on functions.php file
- Can’t load WP function into external function
- allow subscribers to see private posts without plug in
- Show comments menu in dashboard only if the site has comment
- Image as Sales Badge
- add_action shortcut?
- WSoD being caused by this piece of code
- How to Arrange PHP Files to Allow for Multiple Types of Pages?
- Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?
- Show css depending on activity type in BuddyPress activity-loop [closed]
- remove wp floating submenu in wp dashboard
- ACF: how do I get the fields and its values of a specific group?
- How to complete two other input fields, completed the first
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- Fatal error: Uncaught Error: Call to undefined function test()
- Get page that displays all children of taxonomy parent
- Return a numerical function value in Customizer controls
- How can I get the values of my WordPress $wpdb query in Jquery?
- Function to capture a value and store it in a variable
- edit_comment_link is not showing for comment author
- Css loads very slow [closed]
- Show when user is online/offline in real time on user_profile.php
- Adding a widget function into the php theme file
- My new button is in the wrong place
- Checking array against author id in loop
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- Scrape external webpage for first image and add it to new post
- theme_root returning a truncated URI
- Call to undefined method – Download Monitor
- How can I make an object available through the entire site?
- WordPress admin-ajax.php
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- How to get current post category details inside “loop”?
- How to return a string that has a jQuery and Ajax inside in a shortcode?
- How to check post meta isset or not empty during publish/save post?
- how to changes mobile menu toggle breakpoint in WordPress
- remove_action from parent theme using child theme functions.php
- apply_filters() function
- Increase Comment Author Gravatar Size On WordPress Default Comment Function
- Using tag to output text in Genesis?
- display php code in header using wp_head()
- Sorting Problem
- Dynamic Email Handler with ‘header (“Location: …’
- WooCommerce: write featured image dimensions to custom fields in product’
- Generate and upload screenshot as featured image for user-submitted post
- a problem in class in class-wp-hook.php
- transition_post_status hook, works – but not if the post is new
- change title of page dynamically
- Custom plugin doesn’t show in admin menu – when code added, displays an empty page
- How to automatically flush permalinks?
- Execute wp_after_insert_post after the permalink is customized
- Display endpoint’s return into a file (file_put_contents())
- How to change product title color in shop page if product has specific product tag (Woocommerce)?
- Exclude function for custom pages, exclude custom ACF fields