Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #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,
    Sophie

    #930672

    Well 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)

    #930681

    maybe you got a livelink? because tribe events got a lot of view possiblities with each single-event.php ( lists, day, month, etc)

    #931077

    Hi Sophie,

    Did you try the suggestions above and did you have any luck with them? Thanks @guenni007 for helping out :-)

    Best regards,
    Rikard

    #933626

    Hi 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,
    Sophie

    #934022

    Hi 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,
    Victoria

    #938812

    Hi 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,
    Sophie

    #938821

    this 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 answer

    it 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, 7 months ago by Guenni007.
    #938846

    this 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 updates

    Edit:

    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, 6 months ago by Guenni007.
    #938878

    Hi Guenni007,

    awesome, this is working fine! Thank you for your help and for sharing your knowledge. Great :-) !

    Kind regards,
    Sophie

    #938951

    Hi 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,
    Rikard

    #939192

    your welcome

    #939229

    Thank you again so much :-) ! You can close this out now.

    Kind regards,
    Sophie

    #939551

    Hi Sophie,

    Great, thanks for letting us know. Please open a new thread if you should have any further questions or problems.

    Best regards,
    Rikard

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Single event title in Events Calendar H2 instead of H1’ is closed to new replies.