Support

Account

Home Forums Backend Issues (wp-admin) get_object returns illogical JSON object instead of key/value

Unread

get_object returns illogical JSON object instead of key/value

  • I recently cloned my existing database into a development site, and have been stung by a bug that I can’t reproduce in the production environment. Current WordPress v6.6.1, ACF PRO plugin v6.3.5.

    A custom field whose values appear totally normal on the front end, but get_object returns a totally illogical JSON object instead of a value.

    Array
    (
        [0] => Array
            (
                [value] => s:68:"a:2:{s:5:"value";s:11:"city-living";s:5:"label";s:11:"City Living";}";
                [label] => s:68:"a:2:{s:5:"value";s:11:"city-living";s:5:"label";s:11:"City Living";}";
            )
    )

    The exact same code works on the production site! A screenshot of the field group configuration is attached. It looks totally normal.

    The code snippet from the page template is:

    <?php
    $location_types = get_field('type_of_location');
    print_r($location_types);
    if ($location_types) :
        foreach ($location_types as $location_type) { ?>
        <p><span><img />.png">  </span><span><?php echo $location_type['label'] ?></span></p>
    <? }
        endif;
    ?>

    Can anyone help me figure out why this wouldn’t work and/or troubleshoot how the field group somehow is set up incorrectly in the database, but looks fine on the front end?

    I’d be delighted for this to be something dumb, but I doubt it.

    Thank you all!

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.