0

我制作了一个自定义主题和一些自定义页面模板。其中两个模板具有相同的循环。它们都列出了父页面的子页面。不知何故,在 5 个子页面之后,循环决定弄得一团糟,并将最后两个子页面放在一起。

它会破坏页脚并在不应该插入的地方插入代码。这个结果可以看@http ://spkow.com/sites/megatec/ ?page_id=16

我知道我还不是最好的程序员。到底是怎么回事?

<div id="parent_top_content">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(__('Read more'));?>
<?php endwhile; else: ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
</div>
<div id="parent_content_wrapper">
<?php
$pageChildren = get_pages('sort_column=menu_order&hierarchical=0&child_of='.$post->ID);
if ( $pageChildren ) {
foreach ( $pageChildren as $pageChild ) {
echo '<a class="parent_list_link" href="'. get_permalink($pageChild->ID) .'"><div   class="parent_list_element"><div class="parent_list_thumb">' . get_the_post_thumbnail($pageChild->ID, 'thumbnail') . '</div><div class="parent_list_inner"><h3 class="parent_list_title">' . $pageChild->post_title.'</h3>';
if (!empty($pageChild->post_excerpt)){
echo '<p class="parent_list_excerpt">' . $pageChild->post_excerpt.'</p></div><span id="clear">&nbsp;</span></div></a>';
}
}
}
?>
<?php wp_reset_query(); ?>
</div>
4

1 回答 1

1

您正在打开所有子页面的链接,但只有在子页面有摘录时才关闭它,从而导致 html 无效。请参阅w3c 验证器

尝试修复它(以及其他 html 错误),看看是否有帮助。

于 2013-05-20T14:59:16.883 回答