在wordpress中动态创建一个新的div
我在 WordPress 3 中使用下面的代码来获取并限制发布到父级的子页面数量。帖子片段将放入 div 中。当他们达到 7 时,我想创建一个新的 div 并将其限制为 7 等等。一旦帖子达到 7,创建一个新的 div 并获取下一个 7。
请参阅下面的代码。
<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>
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
$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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
未经测试,但也许是这样的
Not tested but maybe something like this