Support

Account

Home Forums Front-end Issues get_field() return null on live server, but on development server works fine

Solving

get_field() return null on live server, but on development server works fine

  • Hello,

    I spent whole day trying to solve this…

    I have development server, and ACF works without any problem.

    When I migrated site to a new live server, ACF values are not showing on frontend of website.

    Tried everything I can, like:

    ini_set('display_errors', 1); // just to have
    echo get_the_ID();
    global $post;
    var_dump($post);
    echo '<hr>';
    echo get_field('zvanje');
    echo '<hr>';
    print_r($fields);
    echo '<hr>';
    print_r($iceCustomFields);
    echo '<hr>';
    echo ($iceCustomFields['zvanje']);
    echo '<hr>';
    echo get_field('zvanje', get_the_ID());
    echo '<hr>';
    the_field('titula');
    echo '<hr>';
    var_dump(get_field_objects());

    … but all of that returns nothing (empty), except last two that returns:

    bool(false).

    Also, next two lines are returing NULL:

    var_dump($iceCustomFields->zvanje);
    var_dump($iceCustomFields['zvanje']);

    My custom fields are “zvanje” and “titula” (and few more, but this is just an example).

    I was thinking, are there some PHP requirements I missing on new server? Or is it something with PHP version (but I tried 7.1, 7.2, 7.3 and 7.4).

    Please if you can help. Don’t know how to solve this anymore…

  • Forget to add at the beginning of my code example:

    $iceCustomFields = get_fields();

    Sorry and thank you!

  • How did you move the content from the dev to live servers?

    What types of fields are not showing content?

  • Migration – as usual – export db into file, change all occurrences of old domain to new one. Everything else works fine without problem. I have lot’s of experience in WP.

    It’s not the first time I’m doing this, that’s also why I’m bit confused.

    Two years ago I migrated the same WP instance from same development server, to almost same live server. Difference between those two live servers is in MySQL – on first (where it works, installation two years ago) is 5.6.49 and on second (where I have a problem) is 5.0.12.

    But, all in all, it looks like those ACF variables are not “registered” or something like that… looks like they are not “visible” or accessible on front end. Can I help myself by adding something in functions.php file or something like that?

    Thank you in advance!

  • I don’t know what the problem is yet. That’s why I asked what kind of fields are not showing the correct values. Is it all fields or just some fields?

    For example, a link field stores a serialized array. Altering the value of the link in a text file and then importing that into the DB will likely break that field. Serialized values need special handling. I generally import the db directly and then use this tool to make updates https://interconnectit.com/search-and-replace-for-wordpress-databases/

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

You must be logged in to reply to this topic.