Support

Account

Forum Replies Created

  • @hube2
    Thank you for your prompt response.

    screen shot
    This is a screenshot of the ACF select field settings (note that it includes Japanese text). The choices for this select field are automatically updated when a separate textarea is modified.

    As mentioned in my initial post, I am following the instructions provided here: ACF Guide on Dynamically Populating Select Fields.

    Regarding the code used for display, it is executed via the WordPress REST API. Below is a simplified version of the code. Please note that it may look odd due to simplification, but essentially, it’s just using get_field to retrieve data. Since the select field works correctly with choices that were initially present and after performing an export/import, I believe there is no bug in this code.

    
    <?php
    add_action('rest_api_init', function () {
        register_rest_route(
            'v1',
            'matches/(?P<slug>[a-z0-9_\-]+)',
            array('callback' => 'matchesResponse')
        );
    });
    
    function matchesResponse($request)
    {
        $post_args = [
            'name'              => $param_slug,
            'post_type'         => 'matches',
            'post_status'       => $request['post_status'],
            'posts_per_page'    => -1
        ];
    
        $post_query = new WP_Query($post_args);
    
        if ($post_query->have_posts()) :
    
            while ($post_query->have_posts()) :
    
                $post_query->the_post();
    
                global $post;
    
                $data[] = get_field('opponent', $post->ID);
    
            endwhile;
    
            wp_reset_postdata();
        endif;
    
        print_r($data);
    
        return new WP_REST_Response($data);
    }
    
    
  • When I referred to “ACF settings,” I meant the Export option available under Tools in the ACF section of the admin panel. I was specifically talking about exporting the Field Groups.

    I’m considering setting up a small test site to share for verification purposes, but I’m not sure what the best approach is for that. For now, I plan to contact the developers.

    I would like to keep this thread open as I am also waiting for responses from others.

    Thank you for taking the time to look at my question.

  • I’m honestly just as puzzled. However,

    the fact that exporting and then re-importing ACF settings seems to resolve the issue suggests that the cause might lie within the ACF mechanism itself. Given this, would it be better to contact the support team directly rather than posting on the support forum? (I am an ACF PRO user.)

  • @hube2
    The value-label pairs that were present from the start return as value => label. However, when one of the choices that I have added is selected, it returns as value => value.

  • @hube2
    Thank you for your prompt response.

    Regarding the code used for display, it is executed via the WordPress REST API. Below is a simplified version of the code. Please note that it may look odd due to simplification, but essentially, it’s just using get_field to retrieve data. Since the select field works correctly with choices that were initially present and after performing an export/import, I believe there is no bug in this code.

    
    <?php
    add_action('rest_api_init', function () {
        register_rest_route(
            'v1',
            'matches/(?P<slug>[a-z0-9_\-]+)',
            array('callback' => 'matchesResponse')
        );
    });
    
    function matchesResponse($request)
    {
        $post_args = [
            'name'              => $param_slug,
            'post_type'         => 'matches',
            'post_status'       => $request['post_status'],
            'posts_per_page'    => -1
        ];
    
        $post_query = new WP_Query($post_args);
    
        if ($post_query->have_posts()) :
    
            while ($post_query->have_posts()) :
    
                $post_query->the_post();
    
                global $post;
    
                $data[] = get_field('opponent', $post->ID);
    
            endwhile;
    
            wp_reset_postdata();
        endif;
    
        print_r($data);
    
        return new WP_REST_Response($data);
    }
    
    
  • @hube2 Yes.
    I need both value and label, so I set Return format to Both.

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