title: How to get_field() in posts loop in WordPress?
body: <p>I am trying to create a function for a shortcode to loop through an 'articles' custom post type. This is essentially a downloadable file uploaded by users and is a custom post type without the content field/editor box in the post editor. This custom post type also has a 'download_link' ACF field attached to it which is the location of the file for downloads. This is the href attribute for each post in the feed. However, the field is not generating any output in the function below. However the title is being populated. I know that all the article posts have a value provided for this particular field. Am I missing something? Thanks. </p>
  
  <pre><code>// CREATE A FEED OF ARTICLES WITH LINKS
  function articles_download_feed(){
      $articles_query = new WP_Query(array('post_type' =&gt; 'article', 
          'post_status' =&gt; 'any'));
          if( $articles_query-&gt;have_posts() ){
              $output = '&lt;ul&gt;';
              while( $articles_query-&gt;have_posts() ){
                  $articles_query-&gt;the_post();
                  $articleID = get_the_ID();
                  $title = get_the_title($articleID);
                  if(get_field('download_link', $articleID)){
                      $download = get_field('download_link', $articleID, true);
                  } else {
                      $download = 'ABC';
                  }
                  $output .= '&lt;li&gt;&lt;a target="_blank" href="'.$download.'"&gt;'.$title.'&lt;/a&gt;&lt;/li&gt;';
          }
      $output .= '&lt;/ul&gt;';
      wp_reset_postdata();
      return $output;
      } 
  } add_shortcode('articles_feed', 'articles_download_feed');
  </code></pre>