Home Forums Front-end Issues Graph using the_field() only showing in first 2 posts and no others


Graph using the_field() only showing in first 2 posts and no others

  • Hi guys, I am trying to add a graph on my wordpress website using a custom field. 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)


    <!-- word map  -->
                        <script src=""></script>
                        <script src=""></script>
                        anychart.onDocumentReady(function () {
                          var data = <?php get_field('wordmap_scores'); ?>;                                        
                          // create a tag cloud chart
                          var chart = anychart.tagCloud(data);
                          // set the chart title
                          // set array of angles, by which words will be placed
                          // enable color range
                          // set color range length
                          // display chart


  • what should this look like on the page without the ACF call?

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

    what does the code in the page actually look like when the page is loaded with the ACf call?
    What kind of field is it and what is stored in it?

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.