我有一个wordpress查询,输出包含以下信息的帖子:-年份-链接到pdf文件-标题-帖子图像
因此,它本质上是一个可追溯到19世纪60年代至今的年度报告档案。早期,每年都没有pdf文件/帖子。在某些年份的较新时期,每年有多个文件。
我需要查询以输出具有以下配置的UL:
<ul>
<li class="decimal-year pdf-present"><a href="#">1860</a><div>Image, Title, PDF Link in Post</div></li>
<li class="normal-year pdf-present"><a href="">1861</a><div>Image, Title, PDF Link in Post</div></li>
<li class="normal-year no-pdf"><a href="#">1862</li>
</ul>
因此,如果该类的“十进制”年份(如1860、1870、1880等)或介于1861、1862、1863等年份之间的年份,则该类应包含信息。然后需要有一个类来说明是否有相应的年报。(链接将显示在视觉时间线上)因此,即使没有年度输出,仍然需要一个li元素。如果一年中有多个文件,那么div中应该有另一个包含数据的ul。我知道这是一个相当大的疑问!
目前的查询如下:
// set the query
$query = array (
\'post_type\' => \'jahresberichtpdf\',
\'orderby\' => \'jahresberichtjahr\'
);
// loops
$queryObject = new WP_Query($query);
if ($queryObject->have_posts()) : ?>
<?php while ($queryObject->have_posts()) : ?>
<?php $queryObject->the_post(); ?>
<li>
Title:<?php the_title(); ?>
Thumbnail:<?php the_post_thumbnail(\'thumbnail\'); ?>
<strong>PDF:</strong> <?php print_custom_field(\'jahresberichtfile:to_link\'); ?>
<strong>Year:</strong> <?php print_custom_field(\'jahresberichtjahr\'); ?>
</li>
<?php endwhile; ?>
<?php endif; ?>
有没有人做过这样的查询,或者愿意接受挑战?如果有人愿意付出一些努力,我会以贝宝捐赠的形式表示感谢!谢谢mark