douyin9987 2012-03-29 11:47
浏览 28

从高级自定义字段列出具有多个日期的帖子

I have posts with ACF repeater date fields showing the beginning of an event.

Advanced custom fields has a feature which allows posts to have repeater fields added it it. So I added a repeater date field, so one post can have multiple dates associated with it.

Now I want to list events by the date. I figured out, how to list them by the first date, but how would I go on about listing all of the posts in one list?

Here is the code I have until now (I'm a noob at php):

<?php $posts = get_posts(array(
'numberposts' => -1,
'category' => array('8,11,12'),
 'orderby_field' => 'trip_dates_0_start', // order of posts by this field
 'orderby_type' => 'date', 
 'order' => 'ASC' ));
if($posts)
{ foreach($posts as $post) : ?> 

<?php while(the_repeater_field('trip_dates')): ?>
<?php the_sub_field('start'); ?>
-
<?php the_sub_field('finish'); ?>
<?php endwhile; ?>
<?php the_title(); ?>
<?php endforeach; } ?>

Now one post would repeat the date field, but be sorted by the first one of them. How do I repeat the post and each have one date? Even if you can't help me with the code, I'd like to know the logic behind creating something like this.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
    • ¥15 gdf格式的脑电数据如何处理matlab
    • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
    • ¥100 监控抖音用户作品更新可以微信公众号提醒
    • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
    • ¥70 2048小游戏毕设项目
    • ¥20 mysql架构,按照姓名分表
    • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
    • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
    • ¥15 linux驱动,linux应用,多线程