Support » Plugins » Hacks » Default Gallery fails HTML validation

  • Hello. I tryed Googling around for my issue.. But i think i didnt manage to find exactly what im looking for. The thing is that i have few subpages with gallery (default wordpress that opens in Lightbox(but thats not issue) and when i went to w3c validation for html5 it failed. It gives me
    “Element dl is missing a required instance of child element dd.”
    </dt></dl><dl class=’gallery-item’>”

    Im not using titles on my images, is that a problem? Because i dont need them. Is there any way to edit functions.php for gallery to stop echoing this? What will i loose if it stops,and will i have to redo all galleries again so it applies to them? I tryed removing that attribute in media.php but nothing happened.
    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • If you’d like, you can create your own gallery markup using the post_gallery filter.

    function custom_post_gallery($html, $attr) {
      return '<p>My super awesome gallery html.</p>';
    add_filter('post_gallery', 'custom_post_gallery', 10, 2);

    Other than that, you can choose to not use the dd, dt, and dd elements if you would like. You just need to pass the following attributes to the shortcode:

    * itemtag
    * icontag
    * captiontag

    Hope this helps!

    Hello, sorry for not being able to answer sooner. First of all thank you for your reply. But is it normal that wordpress gallery doesnt pass w3c html5 validation by default, or did i mess something up?

    Im not that good at php, so i dont think i can manage to “return” all the data for my own gallery..
    You gave me an idea, so i will try to find online some custom gallery function that replaces default one, and maybe passes validation.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Default Gallery fails HTML validation’ is closed to new replies.