-
AuthorPosts
-
March 21, 2018 at 3:53 pm #930634
Hi,
I just recognized that the heading of the title in single event post of Events Calendar is using heading H2 instead of H1. But for SEO reasons it should be H1, shouldn’t it? Can you please tell how to change from H2 to H1?
Thank you for your kind help in advance.
Kind regards,
SophieMarch 21, 2018 at 4:56 pm #930672Well i think it is in :
single-event.php template.
Look for :<?php the_title( '<h2>', '</h2>' ); ?>
i try to find a child-theme solution now – but meanwhile you can change it here quick and dirty
btw: on non pro version the actual version has:
<?php the_title( '<h1 class="tribe-events-single-event-title">', '</h1>' ); ?>
so it might be on actual version the h1 ( but couldn’t serve this into troubles if you using f.e. a masonry of envents ? – than you will have multipel h1 on one page – and that is against good seo rules)
March 21, 2018 at 5:06 pm #930681maybe you got a livelink? because tribe events got a lot of view possiblities with each single-event.php ( lists, day, month, etc)
March 22, 2018 at 7:23 am #931077Hi Sophie,
Did you try the suggestions above and did you have any luck with them? Thanks @guenni007 for helping out :-)
Best regards,
RikardMarch 27, 2018 at 12:52 pm #933626Hi Guenni007,
Hi Rikard,thank you for all your efforts, really do appreciate :-) . I am using Enfold Church Demo (in a Child Theme) with The Events Calendar free version. Here is an example link: https://kriesi.at/themes/enfold-church/event/corn-crop-festival/ . The title (here “Wedding Service”) is in H2. I would love to have this in H1.
Guenni007, what do you mean by saying “but couldn’t serve this into troubles if you using f.e. a masonry of envents ? – than you will have multipel h1 on one page – and that is against good seo rules“? Do you mean the Enfold Masonry Element?
I thank you for all your help in advance :-) .
Kind regards,
SophieMarch 28, 2018 at 6:52 am #934022Hi Sophie,
You need to modify /wp-content/themes/enfold/config-events-calendar/views/single-event.php to change the title tag there.
If you need further assistance please let us know.
Best regards,
VictoriaApril 8, 2018 at 4:18 pm #938812Hi Victoria,
I modified /wp-content/themes/enfold/config-events-calendar/views/single-event.php to change the title tag and it is working. Thank you! But how can I make it safe after update? I am using Enfold Child Theme, what do I have to do?
Thank you and best regards,
SophieApril 8, 2018 at 4:40 pm #938821this was my intend : if you replace all single-event headings with h1 – a masonry or a list of those events could cause that there are multiple h1 on one page – that is not good html programming. a H1 should always be unique – like an ID on one page.
A lot of plugins knows about that so it is on common not the case to have then in a list like here. https://kriesi.at/themes/enfold-church/events/ more than one h1.
Code changed – see the next answerit will do the trick – but i try to preserve the classe set on h2 to give to the h1 too
this code looks for a h2 following the av-single-event-content class and replaces it to a h1
i do not have a test environment here – so you could see if it does the job- This reply was modified 6 years, 8 months ago by Guenni007.
April 8, 2018 at 5:30 pm #938846this to functions.php of your child theme
function replace_h2_on_single_events(){ ?> <script> (function( $ ) { $(document).ready(function() { $('.av-single-event-content h2').replaceWith(function(){ $newTag = $("<h1>", {html: $(this).html()}); $.each(this.attributes, function(i, attribute){ $newTag.attr(attribute.name, attribute.value); }); return $newTag; }) }); }(jQuery)); </script> <?php } add_action('wp_footer', 'replace_h2_on_single_events');
all attributes of the former h2 will stay on position !
so if you like to do it via this way – change back the changing on source code of single event. The next update will do that too.
This functions.php solution is then regardless from updatesEdit:
This is a nice replace script an easier to understand – you can add different rules here
function replace_tags_with_tags(){ ?> <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('.av-single-event-content h2', '<h1></h1>'); // each replacement separated by semi-colon }(jQuery)); </script> <?php } add_action('wp_footer', 'replace_tags_with_tags');
- This reply was modified 6 years, 7 months ago by Guenni007.
April 8, 2018 at 9:03 pm #938878Hi Guenni007,
awesome, this is working fine! Thank you for your help and for sharing your knowledge. Great :-) !
Kind regards,
SophieApril 9, 2018 at 6:00 am #938951Hi Sophie,
Great, glad you got it working. Please let us know if you should need any further help on the topic or if we can close it.
Thanks @guenni007 for helping out :-)
Best regards,
RikardApril 9, 2018 at 1:55 pm #939192your welcome
April 9, 2018 at 2:17 pm #939229Thank you again so much :-) ! You can close this out now.
Kind regards,
SophieApril 10, 2018 at 4:43 am #939551 -
AuthorPosts
- The topic ‘Single event title in Events Calendar H2 instead of H1’ is closed to new replies.