WordPress.org

Ready to get started?Download WordPress

Forums

Default Gallery fails HTML validation (3 posts)

  1. epiric
    Member
    Posted 5 months ago #

    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

  2. nickohrn
    Member
    Posted 5 months ago #

    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!

  3. epiric
    Member
    Posted 4 months ago #

    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.

Reply

You must log in to post.

About this Topic

Tags

No tags yet.