Tagged: , ,

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #343928
    Mantu2
    Participant

    Hi,

    I am just trimming my website and Google insights cave me an small notice in Accebility tree. The test failed: Links must have discernible text. header#masthead > div.wrapper > div#mobile-header-left-menu > a#header-left-menu

    So basically it is missing some text to bots and AI to use it. How can I fix this? I’m using a child theme.

    #343929
    minal
    Keymaster

    Hello @Mantu2:

    Add the following CSS snippets to the additional CSS.

    
    #header-left-menu .mobile-menu-text {
       display: block !important:
    }
    

    Go to Dashboard > Appearance > Customizer > Additional CSS then paste your code over there.

    Hope it works for you.

    Sincerely,

    Minal

    #343931
    Mantu2
    Participant

    Hi,

    I tried this, emptied cache, but nothing changed. I do use multisite, perhaps that have something to do with it?

    #343934
    Mantu2
    Participant

    Kinda worked. So. Now the same error came, but for right mobile menu. I can see MENU-text on the left menu, but right menu is missing text. I did add text

     

    #header-right-menu .mobile-menu-text {

    display: block !important;

     

    But didn’t happen a thing.

    #343935
    minal
    Keymaster

    Hello @Mantu2:

    Add the following code on your js

    
    
    document.addEventListener("DOMContentLoaded", function () {
      document.querySelectorAll(".mobile-menu-text").forEach(function (el) {
      const link = el.closest("a");
        if (link && !link.hasAttribute("aria-label")) {
          link.setAttribute("aria-label", el.textContent.trim());
        }
      });
    });
    
    
    
    

    Hope it works for you. And if it works, you can remove the CSS we gave you earlier.

    Sincerely,
    Minal

    #343941
    Mantu2
    Participant

    Can you be more accurate which .js should this be put, thanks.

    #343946
    minal
    Keymaster

    Hello @Mantu2:

    Sorry for the confusion,

    Here is the updated code, and add it to your child theme functions.php

    
    add_action('wp_footer', function () {
    ?>
    	<script>
    
    document.addEventListener("DOMContentLoaded", function () {
     document.querySelectorAll(".mobile-menu-text").forEach(function (el) { 
       const link = el.closest("a"); 
       if (link && !link.hasAttribute("aria-label")) {
         link.setAttribute("aria-label", el.textContent.trim()); 
       }
      });
     });
    	</script>
    <?php
    });
    
    

    Sincerely,
    Minal

    #343953
    Mantu2
    Participant

    Thanks, that seemed to work!

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