WordPress.org

Support

Support » Themes and Templates » [Resolved] Having trouble validating sidebar if no widgets are on

[Resolved] Having trouble validating sidebar if no widgets are on

  • http://lunaz.homelinux.net/~wpdemo/

    I’m trying to get valid xhtml 1.0 strict as much as possible, and it’s working right with widgets turned on, but if no widgets, I get errors.

    I read somewhere on here to put a UL tag outside everything to get the widgets to validate, that worked.

    Now turning off widgets I get:

    Error Line 222, Column 4: document type does not allow element "h2" here; assuming missing "li" start-tag
    
    <h2>Archives</h2>
    
    Error Line 241, Column 5: end tag for "li" omitted, but OMITTAG NO was specified
    
    </ul></div>
    
    You may have neglected to close an element, or perhaps you meant to "self-close" an element, that is, ending it with "/>" instead of ">".
    Info Line 222, Column 1: start tag was here

    Here’s my sidebar.php

    <ul class="ul-wrapper">
    <?php if ( function_exists('dynamic_sidebar') && function_exists('wp_nav_menu') && dynamic_sidebar(1) ) : else : ?>
    
    <h2>Archives</h2>
    <ul class="li_archives">
    <?php wp_get_archives('type=monthly'); ?>
    </ul>
    
    <h2>Meta</h2>
    <ul class="li_reg">
    <li><?php wp_register(); ?></li>
    </ul>
    
    <ul class="li_loginout">
    <li><?php wp_loginout(); ?></li>
    </ul>
    
    <?php endif; ?>
    </ul>
Viewing 4 replies - 1 through 4 (of 4 total)
  • According to the theme checker I need to put this in:

    <!DOCTYPE html>
    <html <?php language_attributes(); ?>>
    <head>

    instead of a hard coded strict doctype from the w3. NOw I get even more errors trying to validate. The documentation here has no solution for validating XHTML? What do I do?

    OK got this working instead, passes validation and theme checker

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    <head>

    Still having issues with getting sidebar to validate…

    esmi
    Forum Moderator

    @esmi

    The theme checker doesn’t insist on an HTM5 DOCTYPE. Only that you don’t hardcode the <html> attributes. Try using:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html <?php language_attributes(); ?> xmlns="http://www.w3.org/1999/xhtml">

    check into the error:
    Error Line 222, Column 4: document type does not allow element "h2" here; assuming missing "li" start-tag

    li tag is missing. After < ul > tag, < li > will be next, not < h2 >.

    check this code, this will be okey:

    <ul class="ul-wrapper">
    	<?php if ( function_exists('dynamic_sidebar') && function_exists('wp_nav_menu') && dynamic_sidebar(1) ) : else : ?>
    
            <li>
                <h2>Archives</h2>
                <ul class="li_archives">
                <?php wp_get_archives('type=monthly'); ?>
                </ul>
            </li>
    
            <li>
                <h2>Meta</h2>
                <ul class="li_reg">
                <li><?php wp_register(); ?></li>
                </ul>
            </li>
    
            <li>
                <ul class="li_loginout">
                <li><?php wp_loginout(); ?></li>
                </ul>
            </li>
    
        <?php endif; ?>
    </ul>

    YES IT WORKS!!! <3 Thanks much! 🙂
    3/3 resolved, this is a nice forum.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Having trouble validating sidebar if no widgets are on’ is closed to new replies.