-
AuthorPosts
-
October 23, 2025 at 12:19 am #1490521
Hi, I’ve tried multiple codes to remove the image title on mouse hover, but it’s not disappearing.
It doesn’t show up if I’m logged into wp-admin, but once I logout I still see it.
Using Chrome on Mac
Codes I’ve tried
Quick CSS
/*Remove image title on hover*/ img[title] { pointer-events: none; }Functions.php
/*Remove image alt text on hover*/ function remove_title_attr(){ ?> <script> jQuery(window).on('load', function(){ jQuery('#wrap_all a').removeAttr('title'); jQuery('#wrap_all img').removeAttr('title'); }); </script> <?php } add_action('wp_footer', 'remove_title_attr');October 23, 2025 at 7:08 am #1490524Hey sjahan,
Thank you for the inquiry.
We’ve made a few edits to the script — please try it again. Make sure to clear your cache before checking the page.
/* remove image and link title attributes on hover */ function remove_title_attr(){ ?> <script> jQuery(document).ready(function($){ $('#wrap_all a, #wrap_all img').removeAttr('title'); }); </script> <?php } add_action('wp_footer', 'remove_title_attr');Best regards,
IsmaelOctober 23, 2025 at 7:42 am #1490529Hi, I cleared my cache and also tried in an incognito window and another laptop that hasn’t visited the site before but I still see the hover text
October 23, 2025 at 7:56 am #1490531Hi,
We edited the functions.php file and adjusted the priority of the action hook. It should be working properly now.
Best regards,
IsmaelOctober 23, 2025 at 8:37 am #1490532Hi, thank you! That seems to have worked on the Services page which uses the Image box, but I still see it on the Home and About pages that are leveraging the Masonry Gallery. I’ve cleared my cache again just to double check but it’s still there. Do you see it on your end?
October 23, 2025 at 10:31 pm #1490549Hi,
Try this in your child theme functions.php:function remove_tool_tip() { ?> <script> window.onload = function() { var links = document.querySelectorAll('a, img, *[title]'); for (var i = 0; i < links.length; i++) { var link = links[i]; link.onmouseover = function() { this.setAttribute("data-tooltip", this.title); this.title = ""; }; link.onmouseout = function() { this.title = this.getAttribute("data-tooltip"); }; link.onmousedown = function() { this.title = this.getAttribute("data-tooltip"); }; } }; </script> <?php } add_action( 'wp_footer', 'remove_tool_tip', 99 );Best regards,
MikeOctober 23, 2025 at 11:32 pm #1490551That seems to have worked, thank you!
October 24, 2025 at 6:38 am #1490556 -
AuthorPosts
- The topic ‘Image Title on Hover’ is closed to new replies.
