Graph using ACF the_field() only showing in first 2 posts


I am trying to add a graph on my wordpress website using a custom field via ACF. I call the field using the_field() then build the chart with anychart using the field as the input. However, the charts are only being generated for the first two posts and not any else.

I tried changing the data input to the hardcoded values that are in the custom field and that works fine, so there is some issue calling it programmatically. This is within the single.php file.

Does anyone know why this problem exists and why it happens for all posts except the first two?

Here is the code and images of the problem (first image has the post where it works, but in the second you can see the graph is not loaded properly)

In the custom field, the text is in the following format:

<!-- word map  -->

<script src=""></script>

<script src=""></script>


anychart.onDocumentReady(function () {

var data = <?php get_field('wordmap_scores'); ?>;                                        

var chart = anychart.tagCloud(data);


Y Ahmed 4 months 0 Answers 16 views 0

Leave an answer