Support

Account

Home Forums General Issues get_field not returning anything inside wp_query loop

Unread

get_field not returning anything inside wp_query loop

  • Been struggling with this for a while now and would really like some help!

    Here’s my code:

    <?php
    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query('cat=3&showposts=10'.'&paged='.$paged);
    ?>
    
    <article class="innerwrap" id="content">
    
    	<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    	<div class="testimonial">
    
    		<?php $job_title = get_field('job_title'); ?>
    		<?php $photo = get_field('photo'); ?>
    
    		<?php echo($photo); ?>
    
    		<div class="testimonial"><?php the_content(); ?></div>
    
    		<div class="tname"><?php the_title(); ?> - <?php echo($job_title); ?></div>
    
    	</div>
    
    <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    
    <?php endif; ?>

    Basically it’s a testimonial page. I want it to loop through all the posts and get the job title and photo for each testimonial.

    ATM it’s not returning anything.

    I also tried:

    get_field(‘job_title’, $post_id );
    and
    get_field(‘job_title’, $post->ID);

    TIA!

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.