{"id":5451818,"date":"2014-11-05T05:13:28","date_gmt":"2014-11-05T05:13:28","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/get_field-not-working-after-loop-1\/"},"modified":"2016-08-22T04:08:12","modified_gmt":"2016-08-22T04:08:12","slug":"get_field-not-working-after-loop-1","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/get_field-not-working-after-loop-1\/","title":{"rendered":"get_field not working after loop"},"content":{"rendered":"<p>I just put a loop into my static home page custom template, working great. Now I&#8217;ve installed Advanced Custom Fields and have it set up. get_field() is not working for me in the custom page template &#8211; it works above the loop in the template source code but not below the loop. Here is my loop code:<\/p>\n<pre><code>&lt;?php $latest = new WP_Query(&#039;showposts=3&#039;); $count = 0; ?&gt;\n&lt;?php while( $latest-&gt;have_posts() ) : $latest-&gt;the_post(); ?&gt;\n\n&lt;? \t\/\/ prevent dotted border on top of first excerpt\nif ($count === 0) { echo &#039;&lt;p class=&quot;excerpt_title_p_first&quot;&gt;&#039;; $count = 1; } else { echo &#039;&lt;p class=&quot;excerpt_title_p&quot;&gt;&#039;; }\n?&gt;\n&lt;?php the_title( sprintf( &#039;&lt;a href=&quot;%s&quot; rel=&quot;bookmark&quot; class=&quot;excerpt_title_a&quot;&gt;&#039;, esc_url( get_permalink() ) ), &#039;&lt;\/a&gt;&#039; ); ?&gt;&lt;\/p&gt;\n\n&lt;p class=&quot;excerpt_date&quot;&gt;&lt;?php fccp_posted_on(); ?&gt;&lt;\/p&gt;\n\n&lt;p class=&quot;excerpt_content&quot;&gt;&lt;?php echo substr(get_the_excerpt(),0,140).&#039;... &lt;a href=&quot;&#039;.esc_url( get_permalink() ).&#039;&quot; class=&quot;excerpt_read_more&quot;&gt;more \u00bb&lt;\/a&gt;&#039;; ?&gt;&lt;\/p&gt;\n&lt;?php endwhile; ?&gt;<\/code><\/pre>\n<p>Why would get_field work above it but not below it? Is there an error in the loop code? Thanks in advance for your help &#8211; I know php but new to wordpress.<\/p>\n<p>EDIT: I did try using get_field(&#8216;{FIELD_NAME}&#8217;,{PAGE_ID}) also with no luck.<\/p>\n<p>https:\/\/wordpress.org\/plugins\/advanced-custom-fields\/<\/p>\n","protected":false},"template":"","class_list":["post-5451818","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/5451818","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/5451818\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=5451818"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}