Support

Account

Home Forums Front-end Issues ACF URL Field on Index Page WP Query Reply To: ACF URL Field on Index Page WP Query

  • Thanks for your help, John. I did a var_dump that returned NULL.

    This is a WP Query outside of the Loop. Excuse my not so elegant code as I am a designer, not a developer. The value of the field is a standard URL.

    <?php
    $args = array( 'posts_per_page' => 8 );
    $variable = get_field('link', $post->ID);
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post();
    echo '<li>';
    		echo '<div class="img-container">';
    		the_post_thumbnail();
    		echo '</div>';
    		echo '<div class="news-container">';
    		echo '<h3>';
    		echo '<a href="';
    		the_permalink();
    		echo '">';
    		the_title();
    		echo '</a>';
    		echo '</h3>';
    		echo '<p class="date">';
    		the_date();
    		echo '</p>';
    		the_excerpt();
    		echo '<h4>';
    		echo '<a href="';
    		echo $variable;
    		echo '" />';
    		echo 'Read More';
    		echo '</a></h4>';
    		echo '</div>';
    		echo '</li>';
    		endwhile;
    			?>