[wp-hackers] Needed: More Elegant Solution for Using another "the loop"

Mark Shields laebshade at gmail.com
Sun Oct 10 20:59:01 UTC 2004


It worked perfectly and is exactly what I'm looking for.  Thanks!


On Sun, 10 Oct 2004 16:32:06 -0400, Tor Bjornrud <bjornrud at msu.edu> wrote:
> 
> On Oct 10, 2004, at 3:36 PM, Mark Shields wrote:
> > <?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>
> > <?php
> > $postcount += 1;
> > if ($postcount == 1) {
> >       get_breadcrumb(0, 1, 1, 1);
> >       if ($showRoot || $m || $author || $s || $cat) {
> >               echo "<br />";
> >       }
> > }
> > ?>
> > <?php endforeach; else: ?>
> > <?php endif; ?>
> >
> [[snip]]
> > I'd like a more elegant block of code (re: easier/smaller to put it
> > the index.php file) than that.
> 
> I don't know about more elegant, as that's all in the eye of the
> beholder, but this is smaller.  Sorry if this isn't what you're looking
> for.  It assumes three things:
> 
> 1. That the breaking in and out of php isn't needed and you don't care
> about needing those newlines in your html.
> 
> 2. That postcount was intialized to 0 somewhere else above the script.
> 
> 3. That the keys to $posts are the default keys of an array (0, 1, 2, 3)
> 
> <?php if ($posts) : foreach ($posts as $ct=>$post) : start_wp();
> if (!$ct){
>         get_breadcrumb(0, 1, 1, 1);
>         if ($showRoot || $m || $author || $s || $cat) { echo '<br />'; }
> }
> endforeach; else:
> endif; ?>
> 
> _______________________________________________
> hackers mailing list
> hackers at wordpress.org
> http://wordpress.org/mailman/listinfo/hackers_wordpress.org
> 


-- 
- Mark Shields



More information about the hackers mailing list