Old 17-03-2010, 07:45   #1 (permalink)
Pete Nice
Crankshaft
 
Pete Nice's Avatar
 
Join Date: Apr 2003
Posts: 2,107
php help

I'm building a site running on wordpress. I'm pulling all posts out of a category into a grid of 6 per page (2 lines of 3).

What I want to do is echo out a div breaker after each line of 3 posts. I've got it working if there is a total of 3 posts per line but I need to echo it if a new line in the grid has been created:



hit me up.
  Reply With Quote
Old 17-03-2010, 08:14   #2 (permalink)
Hinkle
Pixelpoodle.com
 
Hinkle's Avatar
 
Join Date: Sep 2007
Location: Leuven, Belgium
Posts: 655
not quite sure i understand but can't you just echo the div before post number 4 ( so in the 4th loop before you echo the post ), and have the bottom div fixed in the layout ?
__________________
  Reply With Quote
Old 17-03-2010, 08:19   #3 (permalink)
Zod
Ruler of Planet Houston
 
Zod's Avatar
 
Join Date: Feb 2010
Posts: 131
can you show us the method you are using so far?
__________________
I ain't got time to bleed!
  Reply With Quote
Old 17-03-2010, 08:20   #4 (permalink)
Pete Nice
Crankshaft
 
Pete Nice's Avatar
 
Join Date: Apr 2003
Posts: 2,107
Quote:
Originally Posted by Hinkle
not quite sure i understand but can't you just echo the div before post number 4 ( so in the 4th loop before you echo the post ), and have the bottom div fixed in the layout ?

can't use that method as it doubles up the breaker.
  Reply With Quote
Old 17-03-2010, 08:21   #5 (permalink)
Pete Nice
Crankshaft
 
Pete Nice's Avatar
 
Join Date: Apr 2003
Posts: 2,107
Quote:
Originally Posted by Zod
can you show us the method you are using so far?

just a simple count inside the wp query:

PHP Code:
$counter=1;

if (
$counter == 3) {
print 
"<div class='breaker'></div>";
$counter 0;
}
$counter++; 
  Reply With Quote
Old 17-03-2010, 08:27   #6 (permalink)
Zod
Ruler of Planet Houston
 
Zod's Avatar
 
Join Date: Feb 2010
Posts: 131
Would this not work?

PHP Code:
$counter=0;
while(
mysql_stuff){

if (
$counter == 3) {
print 
"<div class='breaker'></div>";
}


//echo you posts here


if ($counter == 4) {
print 
"<div class='breaker'></div>";
}
$counter++;  


__________________
I ain't got time to bleed!
  Reply With Quote
Old 17-03-2010, 08:43   #7 (permalink)
Hinkle
Pixelpoodle.com
 
Hinkle's Avatar
 
Join Date: Sep 2007
Location: Leuven, Belgium
Posts: 655
Quote:
Originally Posted by Pete Nice
can't use that method as it doubles up the breaker.

I don't see how that would double the breaker ? If you do it in the 4th loop before you echo your post, then it will only echo in case there is a 4th item, when there are only 3 it will just show the static one.
__________________
  Reply With Quote
Old 17-03-2010, 08:45   #8 (permalink)
Pete Nice
Crankshaft
 
Pete Nice's Avatar
 
Join Date: Apr 2003
Posts: 2,107
almost worked Zod - actually Hinkle was right - me being wrong. Thanks y'all.
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive
Web Hosting by Heart Internet, vBulletin © 2000-2009 Jelsoft Enterprises Limited.
Search Engine Optimization by vBSEO 3.0.0 RC8
Web Hosting by Heart Internet