How to Remove Query Strings From WordPress Gravatars

The following code will remove query strings for Gravatars in WordPress. Removing Query Strings can speed up your website for Google Page speed. 

The query starts by a question mark (?), and s= refer to the size. To get better speed result you must remove Query Strings. 

gravatar query string

Here is the simple code that you need to copy and paste inside your function.php file. You can access function.php file from Cpanel or FTP. Search your active theme’s root directory and there you will get function.php file.

					/* Remove Gravatar Query Strings */
add_filter('get_avatar_url', 'jltwp_adminify_avatar_remove_querystring');
function jltwp_adminify_avatar_remove_querystring($url)
    $url_parts = explode('?', $url);
    return $url_parts[0];

If you have properly saved the code then check your Comment Gravatar URL now. You will see all the parameter gone after question mark. This is how to remove query string for gravatars. 

If you are not that tech person, you still can remove query strings by using WP Adminify plugin.

After WP Adminify plugin activation, navigate to the WP Adminify tweaks options panel. Or just follow the path WP Adminify>Tweaks> Comment.

Inside comment, there is a lot of option including “Remove Gravatar Query Strings“.

Just enable this option and save the settings. 

Remove gravatar query strings
Was this article helpful?

© 2021-2024 - Adminify | All rights reserved

WP Adminfy accepted payment methods