2010-12-12 61 views
0

動態創建一個新的div我下面用在WordPress 3這個代碼來獲取並限制發佈到父子頁面的數量。帖子代碼將進入div。當他們打7我想創建一個新的div並將其限制在7等和。一旦崗位打7創建一個新的div並獲得下一個7在WordPress

見下面的代碼。

<div id="folio-content"> 
<?php 
$projectpage = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc&number=7'); 

$count = 0; 
foreach($projectpage as $page) 
{ 
$content = $page->post_content; 
if(!$content) 
continue; 
if($count >= 2) 
break; 
$count++; 
$content = apply_filters('the_content', $content); 
?> 
<div class="thumb-container"> 
<div class="thumb">ID) ?>"><?php echo get_image ("thumbnail",1,1,1,$page->ID);?> 
</div> ID) ?>"><?php echo $page->post_title ?> 
</div> 
<?php 
} 
?> 

</div> 

回答

0

未經測試,但也許這樣的事情

<div id="folio-content"> 
<div class="7-set"> 
<?php 
$projectpage = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc&number=7'); 

$count = 0; 
foreach($projectpage as $page) 
{ 
if(!($count % 7)):?> 
</div><!--/close set!--> 
<div class="7-set"> 
<?php 
endif; 
$content = $page->post_content; 
if(!$content) 
continue; 
if($count >= 2) 
break; 
$count++; 

$content = apply_filters('the_content', $content); 
?> 
<div class="thumb-container"> 
<div class="thumb">ID) ?>"><?php echo get_image ("thumbnail",1,1,1,$page->ID);?> 
</div> ID) ?>"><?php echo $page->post_title ?> 
</div> 
<?php 
} 
?> 
</div><!--/close set!--> 
</div><!--/close folio content!--> 
+0

嘿,謝謝!我會給它一個去,我也有一些想法。再次感謝。 – chad 2010-12-12 15:15:55