Support

Account

Home Forums General Issues get_field not getting value of code

Solving

get_field not getting value of code

  • Having some trouble. The get_field() function isn’t working for one of my text area fields. It works for other fields on the page, and I checked to make sure there weren’t any spelling errors in the field name.

    When I EDIT my page, there is text entered into the field, but the get_field() doesn’t show the value on the actual page. So, the ADMINISTRATION recognizes a value, but the get_field() function isn’t pulling the value.

    I am using CODE in the text area field when I edit the page (it is for a facebook feed). I thought that using code could be causing the problem … however, I’ve done this before (at the top of the same page) and the code showed up fine… For the ACF text area settings, I’ve tried “convert HTML into TAGS”, and have also tried “No Formatting” … but neither works.

    Below is the get_field() code in my template, and beneath that is the actual text/code that I am trying to show on the page.

    
    <?php 
    $social_media_script2 = get_field('social_media_script2');
    ?><!-- Social Media Script: <?php echo $social_media_script2; ?> -->
    <?php 
              if($social_media_script2 != '') { ?>    
                    <div class="home-head">Feed</div>
                    <div class="home-roll">
                            <div class="home-roll-box">
    			<?php echo $social_media_script2; ?>
                            </div>
                    </div><!-- End .home-roll -->
    <?php   } ?> 
    

    And here is the code that I am entering into the text area when I edit the page…
    <div class="fb-activity" data-site="http://www.mysite.com" data-action="likes, recommends" data-width="100%" data-height="400px" data-colorscheme="light" data-header="true"></div>

    If anyone can help, let me know what to do. Thanks!

  • Hi @jabbamonkey

    Can you please debug your data like so:

    
    <?php 
    
    echo '<pre>';
    	print_r(get_field('social_media_script2'));
    echo '</pre>';
    die; ?>
    

    What do you see?

    Thanks
    E

  • Nothing appears …

    Code only shows

    <pre></pre>
    

    See attached for a screenshot of the ACF admin area, and the EDIT PAGE
    view with the field (and the value entered).

  • Hi @jabbamonkey

    Can you please check your DB in the wp_postmeta table that the row exists for your value and the post_id.

    Please make note of the post_id, is this the same post_id as the post you are viewing on the front end?

    Thanks
    E

  • I used get_post_meta to pull the info. Below are the results for social_media_script2 …..

        [social_media_script2] => Array
            (
                [0] => <div class="fb-activity" data-site="http://ridgewood.tipsfromtown.com" data-action="likes, recommends" data-width="100%" data-height="400px" data-colorscheme="light" data-header="true"></div>
            )
    
        [_social_media_script2] => Array
            (
                [0] => field_530b8d2cb5ff9
            )
    
  • Hi @jabbamonkey

    Is this a similar issue to your repeater field not returning data?
    Perhaps the issue is the same for both threads.

    I think the issue may be related to caching of the ACF data. Can you confirm that your site / server does not feature any caching?

    Can you setup a local instal of your website and run it there? Does this fix the issues?

    Thanks
    E

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

The topic ‘get_field not getting value of code’ is closed to new replies.