好的,我已经设置了一些代码,用于搜索ID为8的子页面的所有页面,然后将这些页面的所有附件(在库中)输出为无序列表项 . 你可以在这里看到效果http://goo.gl/eq4UF .
我遇到的问题是我需要在每个页面之前包含每个页面的 Headers ,以便您可以轻松识别哪个图像位于哪个页面下方 . 通常我会添加它,但列表项目使用砌体并使用一些JS定位在整个页面上,因此它们永远不会出现在列表中的第一个图像旁边 .
因此,我将页面的 Headers 添加到 <ul>
中的每个 <li>
,这将允许 Headers 与每个图像一起运行,但我不知道如何将其包含在wp get attachment image函数中 . the_title
和 wp_title
在此循环中都不起作用 . apply_filters( 'the_title', $attachment->post_title );
显然需要图像 Headers ,但是有没有什么好处的页面 Headers ?
先谢谢,希望这是有道理的,R
<?php $postslist = get_pages('number=9999&sort_order=DESC&sort_column=post_date&child_of=8');
foreach ($postslist as $post) :
setup_postdata($post); ?>
<ul class="main-projects-list">
<?php
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post->ID,
'orderby' => 'menu_order',
'order' => 'ASC',
);
$attachments = get_posts( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
echo '<li class="each-image">';
echo wp_get_attachment_image( $attachment->ID, 'large' );
echo '<p>';
echo apply_filters( 'the_title', $attachment->post_title );
echo '</p></li>';
}
}
?>
</ul>
<?php endforeach; ?>
1 回答
你可以试试这个: