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

    Hi,

    I’m using a timeline on my website. For SEO reasons, I want to achieve that the date is not automatically an H2, while the style might remain the way it is. How do I do that?

    Check: https://ml-digital.de/

    Thanks a lot in advance!
    Markus

    #998775

    Hey mrqslmk,
    Try adding this code to the end of your functions.php file in Appearance > Editor:

    function custom_timeline(){
      ?>
      <script>
    jQuery(window).load(function(){
    jQuery('.av-milestone-even h2.av-milestone-date:nth-child(even)').replaceWith(function () {
        return $('<h3/>', {
            html: $(this).html()
        });
     });
    jQuery('.av-milestone-odd h2.av-milestone-date:nth-child(odd)').replaceWith(function () {
        return $('<h3/>', {
            html: $(this).html()
        });
     });
     });
     </script>
     <?php
      }
      add_action('wp_footer', 'custom_timeline');

    Then add this code in the General Styling > Quick CSS field:

    
    .avia-timeline h3 strong {
        color: #858585 !important; 
        font-size: 25px !important; 
    }
    .av-milestone-odd h3 strong {
    float:right !important;
    }

    Best regards,
    Mike

    #998903

    Hi Mike,

    thanks for your help. I just followed the steps you suggested, but it appears to me that it didn’t work. I left it that way on my site so you can check again. And: I’d prefer it not to be an H-headline at all. I think your code is supposed to make an H3 out of the H2 it was previously, right?

    Thank you for helping me – your support is great!

    #998917

    Hi,
    I see you are getting this error: Uncaught ReferenceError: jQuery is not defined
    Can you please include a admin login in the private content area so we can take a closer look.
    I will change the H3 to a span, I assume you still want the text to be the same color and font size though?

    Best regards,
    Mike

    #998926

    Hi Mike,

    To be honest, I didn’t see that error. I just followed your list and then I checked on the frontend and could not see a difference. You’re right, I’d like to keep size, color etc., I just don’t want it to be tagged as an “Hx”.
    Thank you!

    #998931

    Hi,
    Thank you for the login, I have changed the function and the css, now it is working correctly without any H tags.
    Please clear your browser cache and check.
    Here is the final code:
    functions.php:

     function custom_timeline(){
      ?>
      <script>
    jQuery(window).load(function(){
    jQuery('.av-milestone-even h2.av-milestone-date:nth-child(even)').replaceWith(function () {
        return jQuery('<span/>', {
            html: jQuery(this).html()
        });
     });
    jQuery('.av-milestone-odd h2.av-milestone-date:nth-child(odd)').replaceWith(function () {
        return jQuery('<span/>', {
            html: jQuery(this).html()
        });
     });
     });
     </script>
     <?php
      }
      add_action('wp_footer', 'custom_timeline');
    

    CSS:

    .avia-timeline span strong {
        color: #858585 !important; 
        font-size: 25px !important; 
    }
    .av-milestone-odd span strong {
    float:right !important;
    }

    Best regards,
    Mike

    #998932

    Hi Mike,

    thank you, but on my end (and I did clear my browser cache) the “date” contents are still H2s?

    #999000

    Hi,
    Ok, I made a few more changes, Please clear your browser cache and check.
    New final functions.php:

    function custom_timeline(){
      ?>
      <script>
    jQuery(window).load(function(){
    jQuery('.av-milestone h2.av-milestone-date').replaceWith(function () {
        return jQuery('<span/>', {
            html: jQuery(this).html()
        });
     });
     });
     </script>
     <?php
      }
      add_action('wp_footer', 'custom_timeline');

    New final CSS:

    .avia-timeline span strong {
        color: #858585 !important; 
        font-size: 25px !important; 
    }
    .av-milestone-odd span strong {
    float:right !important;
    }
    .avia-timeline-vertical.av-milestone-placement-alternate li.av-milestone-even > span:first-child {
        display: none;
    }

    Best regards,
    Mike

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.