我试图使一个加载更多的按钮,将加载更多的图像从我的ACF画廊使用AJAX。但要做到这一点,我需要能够使用wp_query,以便我可以设置每页的帖子数量。那么,是否可以将以下代码转换为wp_query呢?
<?php
$images = get_field('images');
if( $images ): ?>
<?php foreach( $images as $image ): ?>
<div class="col-4 p-0">
<a href="<?php echo $image['url']; ?>">
<img src="<?php echo $image['sizes']['gallery_size']; ?>" alt="<?php echo $image['alt']; ?>" />
</a>
</div>
<?php endforeach; ?>
<?php endif; ?>发布于 2019-02-21 01:19:18
你看过吗:https://www.advancedcustomfields.com/resources/query-posts-custom-fields/
基本上,您可以使用WP_Query通过meta_query查询ACF,并使用WordPress的paginate_links()方法在AJAX中加载更多内容。
希望这能有所帮助。
https://stackoverflow.com/questions/54790842
复制相似问题