Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1169271

    Howdy!
    I use The Event Calendar. The title of an event single page is set to h2 by default. I would like to change this to h1.
    In my search for a solution, I found this thread.

    So far, this solution works, but:
    1. the solution sets all h2 on the event page to h1. I’d like only to change the title
    2. I cannot find a way to apply this solution to a child-heme.

    Do you have any ideas?
    regards
    joerg

    • This topic was modified 4 years, 11 months ago by netgo2017.
    #1170076

    Hey netgo2017,

    Did you try the single-event.php editing or adding the JavaScript code to the functions.php?

    Best regards,
    Victoria

    #1170640

    Hi Victoria!

    single-event.php:
    Works great, but I can’t find a way to add this in my child-theme.

    functions.php:
    Works in child-theme, but this method sets all h2 on the event page to h1, not only the title.

    regards
    Jörg

    #1170882

    Hi,

    Thank you for the update.

    Could you give us a link to the actual event page? Perhaps we can use a different selector in the custom replaceElementTag function to exclude the other h2 in the site and only change the main title.

    Example:

    replaceElementTag('.tribe-events-single-event-title', '<h1></h1>');
    

    Best regards,
    Ismael

    #1170952

    Hi!
    Yes, of course. This is an example.
    Thanks a lot and regards
    Jörg

    #1171007

    Hi,

    Are you using the second script with a function called replaceElementTag from the previous thread? Try to replace this line:

    replaceElementTag('.av-single-event-content h2', '<h1></h1>');   // each replacement separated by semi-colon
    

    with:

    replaceElementTag('.tribe-events-single-event-title', '<h1></h1>');
    

    Best regards,
    Ismael

    #1171093

    Hi Ismael!

    Yes, that works. Thank you very very much!

    @all: here my full code:

    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('.tribe-events-single-event-title', '<h1></h1>');   // each replacement separated by semi-colon
        
      }(jQuery)); 
    </script>
    <?php
    }
    add_action('wp_footer', 'replace_tags_with_tags');

    Best regards
    Jörg

    #1171095

    Hi,

    Glad Ismael could help and thanks for sharing your solution!
    Let us know if you have any other questions or issues :)

    Best regards,
    Yigit

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘enfold with event calendar: change event title from h2 to h1 -SOLVED-’ is closed to new replies.