在wordpress中动态创建一个新的div

发布于 2024-10-07 04:47:38 字数 776 浏览 0 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅沫记忆 2024-10-14 04:47:39

未经测试,但也许是这样的

<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!-->

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!-->
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文