Tagged: header tags, Images
I’d like to change the captions (of some) images to H3, how can i do that? (not just in style, but to make them actual H3)
Hey Peter,
PLease include a link to your page as there are a few different solutions depending on the element used.
Best regards,
Mike
Hi Mike, its for https://fysiobreda.thedigitalmanager.nl/
there is the section on the homepage with ‘hier heb ik pijn’ with images of ‘rug’, ‘schoulder’ & ‘elleboog’ under it. I’d like the caption of those images to become H3.
Hi,
Try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:
function custom_h3_script() { ?>
<script>
(function($) {
$(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('.av-image-caption-overlay-center p', '<h3></h3>');
});
}(jQuery));
</script>
<?php
}
add_action( 'wp_footer', 'custom_h3_script', 99 );
Best regards,
Mike
Hi @Mike. that doesnt seem to work. images are still h1. is there another way to change this?
@mike ! awesome! case closed:) many thanks