I am using this code below in wordpress 3 to get and limit the amount of child pages posted to the parent. The post snippets are going into a div. when they hit 7 I want to create a new div and limit it to 7 and so on and on.. Once the posts hit 7 create a new div and get next 7.
see code below.
<div id="folio-content">
<?php
$开发者_Go百科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>
Not tested but maybe something like this
<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!-->
精彩评论