[wp-hackers] Too Many Queries
    Mark Jaquith 
    mark.wordpress at txfx.net
       
    Wed Dec  6 23:56:04 GMT 2006
    
    
  
On Dec 6, 2006, at 6:30 PM, Andy Mikester wrote:
> So I need to be able to output a <dl> for every month of 2006 and  
> keep in
> the 2006 DIV, and then output a <dl> for every month of 2005 and  
> keep it in
> the 2005 DIV, and so on and so on. Right now the method above works  
> but I am
> querying the database 24 times every time the page is loaded, and  
> the number
> will keep going up as time goes on.
You just need to take my method and make it apply to year changes as  
well as month changes.  For year changes, close two <dl>s and start  
the one for the new year.
In pseudo code:
firstyear = true;
firstmonth = true;
foreach ( posts ) {
	if ( new_year() {
		if ( !firstyear) {
			</month>
			</year>
		}
		firstyear = false;
		<year>Yearname
	}
	if ( new_month() ) {
		if ( !firstmonth )
			</month>
		firstmonth = false;
		<month>Monthname
	}
	<post>
	POST STUFF
	</post>
}
</month>
</year>
something like that.
--
Mark Jaquith
http://txfx.net/
    
    
More information about the wp-hackers
mailing list