Tagged: multiple H1
Good morning,
on my portfolio page, I find 3 H1 tags which penalize SEO
, how can I fix this problem without affecting the rest of the site?
thank you for your comeback
Hey YMen45,
Thank you for the link to your site, the title bar h1.main-title is the correct h1 for the page, but I see that you manually added two more on the page
use the following code at the end of your child theme functions.php file in Appearance ▸ Editor to change the correct one to a “p” tag, and then you can change the two manually added ones to use just one H1 tag.
function custom_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('.page-id-4783 h1.main-title.entry-title', '<p></p>');
}(jQuery));
</script>
<?php
}
add_action( 'wp_footer', 'custom_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
Hi,
The use this to make “Portfolio” h2
function custom_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('.page-id-4783 h1.main-title.entry-title', '<h2></h2>');
}(jQuery));
</script>
<?php
}
add_action( 'wp_footer', 'custom_script', 99 );
and manually change “NOS REALISATIONS EN CREATION DE SITES INTERNET” as h1
“Découvrez notre portfolio” is h2
as they look to be in a text element that you manually added.
Best regards,
Mike
Hi,
Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.
Best regards,
Mike