jeudi 1 janvier 2015

Get the_field of Advanced Custom Fields in a custom query


I have a custom query to display content of a certain template:



<?php
$i = 0;
$pages = get_pages(array(
'meta_key' => '_wp_page_template',
'meta_value' => 'sale.php'
));
foreach($pages as $page){
echo '<div class="content_'. $i .'">' . apply_filters( 'the_content', $page->post_content ) . '</div>';
echo '<div class="title_' . $i . '">' . apply_filters( 'the_title', $page->post_title) . '</div>';
echo '<p>' . the_field('sale_images_url') . '</p>';
$i++;
}
?>


which works fine for the_content() and the_title() so far. Want I also wanna do is, to display the value of an Advanced Custom Field named sale_images_url.


But it displays nothing. Do I have to handle this different?


Thanks





Aucun commentaire:

Enregistrer un commentaire