-2
我正在嘗試顯示自定義帖子類型的圖庫。ACF - 從自定義帖子類型獲取圖庫
我使用Custom Post Type UI插件創建了一個新的Custom Post Type,並將其稱爲'photo'。
我的ACF自定義字段被稱爲「圖庫」。
這是一個單頁的網站,所以我試圖顯示index.php中的圖像。
我開始當包括定期發佈頁面上的畫廊,工作得很好下面的代碼:
<?php
$images = get_field('gallery');
if($images): ?>
<?php foreach($images as $image): ?>
<div class="item" ><img src="<?php echo $image['sizes']['large']; ?>" /></div>
<?php endforeach; ?>
<?php endif; ?>
我現在想拉圖像形成自定義職位類型是這樣的:
<?php
$loop = new WP_Query(array('post_type' => 'photo'));
while ($loop->have_posts()) : $loop->the_post();
$images = get_field('gallery');
if($images): ?>
<?php foreach($images as $image): ?>
<div class="item" ><img src="<?php echo $image['sizes']['large']; ?>" /></div>
<?php endforeach; ?>
<?php endif; ?>
但這不起作用 - 事實上,整個頁面變得空白,就像語法錯誤時一樣。
任何想法如何解決這個問題?
非常感謝!
就是這樣。非常感謝! – user56920