lundi 29 février 2016

Advanced Custom Field Content doesn't show in wordpress loop

I'm having a bit of trouble getting acf content to show within the Wordpress loop. The code I'm using within the page.php template is as follows:

<?php $args = array (
'post_type' => 'test-box'
);
$the_query = new wp_query ( $args);
?>
<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query-   >the_post(); ?>

<?php 
the_field( 'acf_test_box_header' );
the_field( 'acf_test_box_content' );
?>

<?php endwhile; else : ?>

<p>There are no posts to display.</p>

<?php endif; ?>

The problem is that the two fields: acf_test_box_header and acf_test_box_content don't display their content when inside the loop, returning instead 'header 2' and 'content 2'. If I move them outside the loop then they display the content as it was entered fine.

Any ideas?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire