Tagged: widgets
hello, I would like to customize the footer and more particularly the widgets which take the h3 attribute as a title to use a title without an Hx attribute which will be personalized by CSS via .widgettitle
is it possible ?
Hey Webmaster,
To change all of the widget titles from H3 to “p” add this code to the end of your child theme functions.php file in Appearance ▸ Editor:
function custom_widgettitle_script() { ?>
<script>
(function($) {
function replaceElementTag(targetSelector, newTagString) {
$(targetSelector).each(function(){
var newElem = $(newTagString, {html: $(this).html()});
$.each(this.attributes, function() {
newElem.attr(this.name, this.value);
});
$(this).replaceWith(newElem);
});
}
replaceElementTag('h3.widgettitle', '<p></p>');
}(jQuery));
</script>
<?php
}
add_action( 'wp_footer', 'custom_widgettitle_script', 99 );
Please ensure to copy the code from the forum and not an email notification so the symbols are not converted.
Best regards,
Mike
Perfect !
Thank you for your fast and quality support
Best regards,
Hi,
Thanks for the update. Please let us know if you should need any further help on the topic, or if we can close it.
Best regards,
Rikard