Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter vektordesign

    (@vektordesign)

    So I read a ton of php documentation and learned some stuff and came up with this, CHECK IT OUT!

    <?php query_posts('cat=27'); ?>
    	<?php $i = 1 ?>
    	<?php $posts = get_posts('category=27');
    	foreach ($posts as $post) : start_wp(); ?>
    	<div id="<?php the_ID(); ?>" class="story photography_post<?php if($i == 1) echo " first";  ?>">
    		<div class="postwrapper">
    			<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    			<?php $hemingway->excerpt() ?>
    			<div class="details">
    				<?= _('Posted at') ?> <?php the_time('ga \o\n ' . $hemingway->date_format(true) . '/y') ?> | <?php comments_popup_link('no comments', '1 comment', '% comments'); ?> | Filed Under: <?php the_category(', ') ?> <span class="read-on"><a href="<?php the_permalink() ?>">read on</a></span>
    			</div> <!-- close: details -->
    		</div> <!-- close: postwrapper -->
    	</div> <!-- close: <?php the_ID(); ?> -->
    	<?php if($i == 3){$i = 1;} else {$i++;} ?>
    	<?php endforeach; ?>

    There it is. Loops the foreach and puts a first class on 1st and every 3 posts after that. Hope this helps someone.

    Thread Starter vektordesign

    (@vektordesign)

    @xdesi, Thanks for the reply. Multiple loops definitely seem to be a solution, however I actually have like… 5 loops right now anyway and didn’t know what kind of overhead that many loops would incur. Let me dig up my code and I’ll post it: https://pastie.org/270585

    Basically I have 5 loops, consisting of 4 category pulls, each in their own div that slides out on js call, and then the last loop calls 2 regular posts, or will call 2 regular posts excluding the categories 24, 25, 26, 27.

    The four category loops need to have some sort of counter that cycles through a foreach array or something like 'first','',''.

    But I think I’m in over my head.

    Thread Starter vektordesign

    (@vektordesign)

    Ok so I saw a great page on phparadise about arrays, which is what I assume I need to use, and I think I need to add an array to my foreach ($posts as $post) : start_wp(); ?> dealio. any help would be killer.

Viewing 3 replies - 1 through 3 (of 3 total)