Support

Account

Home Forums Front-end Issues Display custom fields of on page with several posts

Helping

Display custom fields of on page with several posts

  • Hello ,

    I Have a page which display several post articles.
    IN the different post articles I would like to display the custom field values but they does not show up .. the posts title and content are displayed but not the acf values.. I don’t understand why.
    Could it be possible that acf does not work with the method query_posts ?

    Thanks

    <?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>
    		<div class="post">
    			<?php the_title(); ?>
    	 <?php endwhile; ?>
    	<?php endif; ?>
    	<?php query_posts('cat=11&post_status=publish,future');?>
    		<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    			<div class="postarticle">
    				<?php the_title(); ?>
    				<img src="<?php the_field('miniature-2');?>" />
    				<p><?php the_content(); ?></p>
    			</div>	
    <?php endwhile; else: endif; ?>		
    	</div>
  • Hi @anselme

    Your loop is fine, have you done any debugging?

    Have you tested this:

    
    <?php 
    
    echo '<pre>';
    	print_r(get_field('miniature-2'););
    echo '</pre>';
    die;
     ?>
    

    Are you 100% sure that ‘miniature-2’ is the correct field name? not ‘miniature_2’?

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Display custom fields of on page with several posts’ is closed to new replies.