PDA

View Full Version : Lists are driving me mad


kingjacob
07-23-2008, 06:08 AM
Anyone able to help out with an annoying problem.?
The top list is running into the bottom. I know the solution is right in my face but I dont see it.

Oh andhttp://houstonvanguard.com

<div class="lsidebar">
<ul>
<h2>Musical Notes</h2>
<?php
global $post;
$myposts = get_posts('numberposts=6&offset=1&category=4');
foreach($myposts as $post) :
?>
<li class="l1"><a href="<?php the_permalink(); ?>"><?php the_thumb("link=p"); ?></a>
<?php endforeach; ?></li>
<p><p>
<h2>Words on Paper</h2>
<?php
global $post;
$myposts = get_posts('numberposts=6&offset=0&category=5');
foreach($myposts as $post) :
?>
<li class="l1"><a href="<?php the_permalink(); ?>"><?php the_thumb("link=p"); ?></a></li>
<?php endforeach; ?>
</ul>
</div>

SarahG
07-23-2008, 08:43 AM
You've messed up your markup there. Your h2s are between a ul and li, which is bound to break stuff (either now or in the future). There's no closing ul, instead you've got an empty paragraph and another h2 between the next list items. You also seem to have two sets of links around each thumbnail, which tells me the_thumb() is outputting the same link, so you can remove the first.

Keep your lists separate if they should be separate, ie. have separate subjects. If you want it all in one list, then use nested lists. Personally I'd go for the following:

<div class="lsidebar">
<h2>Musical Notes</h2>
<ul>
<?php
global $post;
$myposts = get_posts('numberposts=6&offset=1&category=4');
foreach($myposts as $post) :
?>
<li class="l1"><?php the_thumb("link=p"); ?></li>
<?php endforeach; ?>
</ul>

<h2>Words on Paper</h2>
<ul>
<?php
$myposts = get_posts('numberposts=6&offset=0&category=5');
foreach($myposts as $post) :
?>
<li class="l1"><?php the_thumb("link=p"); ?></li>
<?php endforeach; ?>
</ul>
</div>

Also note, you don't need the second global $post; line once it's already there in the file :)

kingjacob
07-23-2008, 11:37 PM
thanks again Sarah, thats one bug down. Now to figure out why the sites messing up in IE

I really need to learn to code properly.