Support

Account

Forum Replies Created

  • Did some additional searching and found this thread on Stack Overflow that showed what I was trying to accomplish. Copying it here, too:

    It will require a little bit of code along with ACF

    Add checkbox field (ex : your_field_name) and add following code in your functions.php file

    function my_acf_load_field( $field )
    {
        global $post;
        $field['choices'] = array();
        wp_reset_query();
        $query = new WP_Query(array(
            'post_type' => 'your-custom-post-type',
            'orderby' => 'menu_order',
            'order' => 'ASC',
            'posts_per_page' => -1,
            ));
        foreach($query->posts as $product_id=>$macthed_product){
                $choices[$macthed_product->ID] = $macthed_product->post_title;
        }
        $field['choices'] = array();
    
        if( is_array($choices) )
        {
            foreach( $choices as $key=>$choice )
            {
                $field['choices'][$key] = $choice;
            }
        }
         wp_reset_query();
        return $field;
    }
    add_filter('acf/load_field/name=your_field_name', 'my_acf_load_field');

    use wp query parameters to filter posts.

    Post id will be the checkbox value with title as label in metabox.

  • This looks like it’s very similar to something I’m trying to accomplish. Do you have an example of how to implement this (after placing it in your functions.php file and changing the ‘post_type’ that is)?

    E.g. Do you create an empty checkbox field with the name “my_field_name” first? Or do you change “my_field_name” to the name of an existing Post Object field?

    Thanks in advance!

  • @James

    The old posts repeater data in wp_postmeta all appear to be correctly set at 0 where appropriate. Example post:

    Database Comparison

    But, when editing an old post in the editor the empty repeater entries appear.

    This behavior does not occur when adding or editing a new post (e.g. a post created after the ACF update that required the database upgrade).

  • Here’s a screen recording.

    And, here’s the JSON export for the Primary Options fields, and here’s a JSON export of everything.

    Hope that helps to explain the issue. I’ve seen this occurring across multiple WordPress installs.

    Thanks again for your help!

  • The 5.0.2 update appears to have corrected this issue. Thanks for your support!

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