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

    • anselme

    • September 3, 2013 at 8:17 pm

    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>
    • Elliot

    • September 4, 2013 at 2:57 pm

    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)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.