I've been pouring over my code for the last 2 days - I'm a compelte novice so it was in a right mess.

It's down to 2 errors now, but no matter how often I look at the code, I can't fathom out what's wrong with it.

Any help much appreciated. I should also have mentioned that I've got 4 widgets in the sidebar. I've tried to add in code for the placing of the 4th widget, but it is stilling showing up with these 2 errors. Thanks again.

Cheers

The 2 errors are :

Line 124, Column 84: document type does not allow element "li" here; missing one of "ul", "ol", "menu", "dir" start-tag.

…chives" class="widget widget_archive"><h2 class="widgettitle">Archives</h2>

Line 131, Column 52: document type does not allow element "li" here; missing one of "ul", "ol", "menu", "dir" start-tag.

…365883691" class="widget widget_text"> <div class="textwidget"><a href="

and the code as follows:

<div id="sidebar">

<ul>

<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar() ) : else : ?>
<
ul>
<li><h2>Archives</h2>
<?php wp_get_archives('type=monthly'); ?>
</ul>
</li>

<ul>
<li><h2>Categories</h2>
<?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0'); ?>
</ul>
</li>

<?php /* If this is a page */ if ( is_home() || is_page() ) { ?>				
<?php get_links_list(); ?>

<ul>
<li><h2>Meta</h2>
<?php wp_register(); ?>
<li><?php wp_loginout(); ?>
<li><a href="http://validator.w3.org/check/referer" title="This page validates as XHTML 1.0 Transitional">Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr></a></li>
<li><a href="http://gmpg.org/xfn/"><abbr title="XHTML Friends Network">XFN</abbr></a></li>
<li><a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress</a></li>
<?php wp_meta(); ?>
</ul>
</li>
<?php } ?>

<?php endif; ?>	

</li>
</li>
</li>

</ul>
</div>

    The first thing I noticed were the tags opening and closing in the wrong order. This:

    <ul>
    <li><h2>Categories</h2>
    <?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0'); ?>
    </ul>
    </li> 

    Should be:

    <ul>
    <li><h2>Categories</h2></li>
    <li><?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0'); ?></li>
    </ul>

    Which is assuming that the category list doesn't add it's own li tags, which it probably does. If that's the case, it might work better like this...

    <h2>Categories</h2>
    <ul>
    <?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0'); ?>
    </ul>

    You also have several open li tags throughout...

    <li><h2>Meta</h2>
    <li><?php wp_loginout(); ?> 

    My guess is the three errant </li> tags near the end are an attempt to force validation from the open tags. You're really close on this one. Just remember the order is the important thing...

    <html>
    	<body>
    		<div>
    			<ul>
    				<li>
    					<p>
    						<span>
    						</span>
    					</p>
    				</li>
    			</ul>
    		</div>
    	</body>
    </html>

      Thanks for the reply easmith. I made the changes that you suggested, but I'm still getting the same 2 errors.

      If I only use 1 widget then all is well, it validates, but when I go to add more widgets, that's when the errors begin. It starts at 7, I add a </li> and it goes down to 2.

      Strangely though, my admin page thinks I'm always using one more widget than I really am. Ie. If I use 1 widget, it says I'm using 2. But, on my widgets page it states the correct number of widgets I'm using.

      Don't know if this is relevant or not, but thought I would mention it anyway.

        My guess would be a widget issue, then. Rather than looking at the Wordpress code itself, open Source View from Firefox. It will show you the code after the PHP is rendered. Look through the widgets and see how they are handling their lists. It might give you a better idea of what to add (or what not to add) to make sure the code validates.

        Also, the widgets might be written assuming you're in Transitional rather than Strict mode (or vice versa). This is less likely to cause problems, but it would be good to dig through the help file for the Widget.

          Cheers. I'll give that a go to see if I can suss it out.

          Thanks for the advice - much appreciated.

            I'm getting really confused now!!! I don't know how I never noticed before, but when I add in a widget, it is overriding the 'Categories' and 'Archives' in the sidebar.

            I was using a custom category widget, so I think this is why I hadn't realised it was replacing the 'Categories' and 'Archives'.

            How can I add new widgets to the sidebar and get it to validate at the same time?

            Cheers.

              That might be a question for the Wordpress forums. The PHP in widgets can vary pretty wildly. Wordpress has a lot of minor requirements to make sure widgets work right and play nice with layouts.

              As an aside, make sure you have upgraded to the latest Wordpress build (2.7.1 I think).

                Cheers. I'll give the Wordpress forums a go.

                I'm using 2.7.1, so good there. Thanks again for your help. Cheers.

                  Write a Reply...