Wednesday 15 August 2012

php - Can I add an ID to the divs in this Wordpress query? -


I am using this PHP snippet to wrap every 12 Wordpress posts in a div.

  & lt ;? Php $ i = 1; Echo '& lt; Div class = "row content-block" & gt; '; If ($ Project-> is_posts ()): while ($ project-> is_pause ()): $ project-> The_post (); Get_template_part ('project', 'content'); If ($ i% 12 == 0) {echo '& lt; / Div & gt; & Lt; Div class = "row content-block" & gt; '} $$ i ++; Endwhile; end if; Echo & lt; / Div & gt; '; ? & Gt;   

Is there any way i can apply unique IDs for line content-block divs? For example block-1 , block-2 , etc /

Yes (edited):

  & lt ;? Php $ i = 1; $ Id = 2; Echo '& lt; Div class = "row content-block" id = "block-1" & gt; '; If ($ Project-> is_posts ()): while ($ project-> is_pause ()): $ project-> The_post (); Get_template_part ('project', 'content'); If ($ i% 12 == 0) {echo '& lt; / Div & gt; & Lt; Div class = "row content-block" id = "block- '. $ Id.' '& Gt;' $ Id ++;} $ i ++; endwhile; if end; echo & lt; / div & gt; ; ';? & Gt;    

No comments:

Post a Comment