Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
Created June 3, 2025 09:58
Show Gist options
  • Save webtoffee-git/9f925301a0b1a9cf8e06df54525a2fd3 to your computer and use it in GitHub Desktop.
Save webtoffee-git/9f925301a0b1a9cf8e06df54525a2fd3 to your computer and use it in GitHub Desktop.
Code to change the related product widget heading from h1 to h3 - By WebToffee (Related products Basic plugin)
<?php> //Do not copy this line of code
add_action('wp_footer', function () {
if (is_product()) {
?>
<script>
jQuery(document).ready(function () {
const container = jQuery('.wt-related-products');
if (container.length > 0) {
const h1 = container.find('.wt-crp-heading');
if (h1.length) {
const h3 = jQuery('<h3>', {
class: h1.attr('class'),
style: h1.attr('style'),
html: h1.html()
});
h1.replaceWith(h3);
}
}
});
</script>
<?php
}
}, 20);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment