【发布时间】:2018-10-11 19:56:20
【问题描述】:
我在我的帖子中创建了一个自定义字段,单个帖子所依赖的行程。因此,例如,我进行了一次公路旅行,每个城市都有一个职位。
现在,在将一次旅行的所有书面帖子收集到一个 wp 查询中之后,我想将它们显示在一种轮播中,以便用户可以看到我在旅行中去过哪些其他城市。
有什么建议在这里使用吗?我真的被困了大约一个星期左右。
顺便说一句,我不是最好的程序员,但我已经尽力了 =)
感谢和干杯 斯蒂芬
【问题讨论】:
我在我的帖子中创建了一个自定义字段,单个帖子所依赖的行程。因此,例如,我进行了一次公路旅行,每个城市都有一个职位。
现在,在将一次旅行的所有书面帖子收集到一个 wp 查询中之后,我想将它们显示在一种轮播中,以便用户可以看到我在旅行中去过哪些其他城市。
有什么建议在这里使用吗?我真的被困了大约一个星期左右。
顺便说一句,我不是最好的程序员,但我已经尽力了 =)
感谢和干杯 斯蒂芬
【问题讨论】:
希望对你有帮助...
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<!-- Getting all the cities of the travel -->
<?php $collection_of_cities_by_travel = get_post_meta( get_the_ID(), 'city_visited', false ); ?>
<?php if( $collection_of_cities_by_travel ) : ?>
<ul class="slick-slider"> <!-- http://kenwheeler.github.io/slick/ 100% recomended-->
<?php foreach ( $collection_of_cities_by_travel as $city ): $city_post = get_the_post( $city ); ?>
<!-- Print the detail of every single city (post) in the travel -->
<li class="slide">
<a href="<?php echo get_the_permalink( $city_post->ID ); ?>">
<?php echo get_the_post_thumbnail( $city_post->ID, 'post-thumbnail' ); ?>
<?php echo get_the_title( $city_post->ID ); ?>
</a>
</li>
<?php endforeach ?>
</ul>
<?php endif; ?>
<?php endwhile; ?>
【讨论】: