Home Forums General Issues get_field not returning anything inside wp_query loop


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:

    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    <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>
    <?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 );
    get_field(‘job_title’, $post->ID);


Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.