on my page category.php file i’m using product listing,
product block loop is ,
product-block , product-block , product-block last
last class no margin-left,
how to define third product “last class” in the category loop?
my content.php
<div class="goods_list catalog_goods">
<div class="goods_item">
<div class="foto">
<div class="shadow"></div><?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail($id, array(220,220)); ?></a>
</div>
<div class="bot">
<a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
<div class="stars"></div>
<div class="order">
<a class="but_buy"><i class="icon-shopping-cart icon-large"></i> Buy </a>
<span class="price">$45.00</span>
</div>
</div>
</div>
</div>
i must define third div good_list catalog_goods last
my category.php file
<div class="catalog_right">
<div class="catalog_goods_block">
<?php if ( have_posts() ) : ?>
<?php twentyeleven_content_nav( 'nav-above' ); ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
/* Include the Post-Format-specific template for the content.
* If you want to overload this in a child theme then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'content', get_post_format() );
?>
<?php endwhile; ?>
You can do with php modulus
%
operator.Lets work with your code.
Add
$count=1
Then in your content.php:
Make the
$count
variable global so it can be accessible.Heres the main part
Remainder of
$count
divided by 3and add:
<div class="goods_list catalog_goods <?php echo $no_margin; ?>">
echo
$no_margin
At the last add:
<?php ++$count; ?>
so it will increment until the loop finishes.