Plugin Author
Phil
(@philsbury)
Hi @steveraven,
It shouldn’t ever spit out blank tags so if it is and you can screenshot the source that’d be good to see.
For the elements themselves, while I don’t think the code is an issue per W3 spec, and search engines won’t be age checked it’s possible to change them to whatever you need using a filter (or two). Here’s an example:
`
add_filter(‘age_gate_logo’, function($markup){
return str_replace(‘h1’, ‘div’, $markup);
}, 10, 1);
add_filter(‘age_gate_messaging’, function($markup){
return str_replace(‘h2’, ‘div’, $markup);
}, 10, 1);
`
Just replace the 'div' with whatever you want to use.
Cheers
Phil
Hi Phil,
Well they’re not actually blank as such – they’ve got lots of files and an image upload in there, none of them showing tags as – well, it’s an image – but the H1 tags are still showing as blank ones, viz-a-viz:
<h1 class="age-gate-heading age-gate-logo"><img src="https://www.midlandsmaidens.com/wp-content/uploads/2018/10/rrtestd-e1539731582819.jpg" alt="Midlands Maidens" class="age-gate-logo-image" /></h1>
I’m not too worried about the H2 tag in the second part of the code, but I’ll certainly try adding the first piece of code into my child theme functions.php and let you know how it goes.
No difference whatsoever in the H1 tags count.
When you say I can ‘change the ‘div’ to whatever I wanted’, how do I do that in the supplied code snippet?
And also, how do I get rid of the H1 tag using the above snippet?
-
This reply was modified 7 years, 1 month ago by
steveraven.
Plugin Author
Phil
(@philsbury)
Hmm, it should have replaced the h1 with a div like this image
In the str_replace above we look for a string of h1 and swap it for a string of div. So changing the div text to, say, span will make the element a span.
If you wanted to remove the whole wrapping element you could do:
add_filter('age_gate_logo', function($markup){
return preg_replace('/<h1 class="(.*?)">(.*?)<\/h1>/', '$2', $markup);
}, 10, 1);
Which should just output just the image tag. This will lose a couple of css classes though, but it should be ok.
As ever with these things you might have to clear your cache before seeing the changes if you’re working straight in a live environment.
Cheers
Phil
Hi Phil,
Yes, the above code snippet solved it!
However after clearing the cache, clearing the cloudflare cache, and pressing f5 for a hard reset, the H1 tag was still appearing – so I ran Crap Cleaner to wipe the lot out.
After this it worked fine, so it’s quite possible that the first set of snippets worked too.