Support

Account

Forum Replies Created

  • So here is what the current logic produces:

    array(3) {
        [
            0
        ]=> array(1) {
            [
                "field_64dfd8bf4bc3e"
            ]=> array(4) {
                [
                    "field_64dfd8bf4bc3f"
                ]=> string(8) "kencraft" [
                    "field_64dfd8bf4bc40"
                ]=> string(8) "Kencraft" [
                    "field_64dfd8bf4bc41"
                ]=> string(69) "http://kencraftboats.wpdev.me/wp-content/uploads/2023/07/kencraft.jpg" [
                    "field_64dfd8bf4bc42"
                ]=> array(2) {
                    [
                        0
                    ]=> array(3) {
                        [
                            "field_64dfd8bf4bc43"
                        ]=> string(13) "21cc_walkdown" [
                            "field_64dfd8bf4bc44"
                        ]=> string(13) "21CC WALKDOWN" [
                            "field_64dfd8bf4bc45"
                        ]=> string(74) "http://kencraftboats.wpdev.me/wp-content/uploads/2023/07/21cc_walkdown.jpg"
                    } [
                        1
                    ]=> array(3) {
                        [
                            "field_64dfd8bf4bc43"
                        ]=> string(13) "25cc_walkdown" [
                            "field_64dfd8bf4bc44"
                        ]=> string(13) "25CC WALKDOWN" [
                            "field_64dfd8bf4bc45"
                        ]=> string(74) "http://kencraftboats.wpdev.me/wp-content/uploads/2023/07/25cc_walkdown.jpg"
                    }
                }
            }
        } [
            1
        ]=> array(1) {
            [
                "field_64dfd8bf4bc3e"
            ]=> array(4) {
                [
                    "field_64dfd8bf4bc3f"
                ]=> string(19) "bayrider_flatbottom" [
                    "field_64dfd8bf4bc40"
                ]=> string(20) "Bay Rider Flatbottom" [
                    "field_64dfd8bf4bc41"
                ]=> string(80) "http://kencraftboats.wpdev.me/wp-content/uploads/2023/07/bayrider_flatbottom.jpg" [
                    "field_64dfd8bf4bc42"
                ]=> array(5) {
                    [
                        0
                    ]=> array(3) {
                        [
                            "field_64dfd8bf4bc43"
                        ]=> string(14) "bay_rider_2460" [
                            "field_64dfd8bf4bc44"
                        ]=> string(14) "BAY RIDER 2460" [
                            "field_64dfd8bf4bc45"
                        ]=> string(75) "http://kencraftboats.wpdev.me/wp-content/uploads/2023/08/bay_rider_2460.jpg"
                    } [
                        1
                    ]=> array(3) {
                        [
                            "field_64dfd8bf4bc43"
                        ]=> string(16) "bay_rider_2260fs" [
                            "field_64dfd8bf4bc44"
                        ]=> string(16) "BAY RIDER 2260fs" [
                            "field_64dfd8bf4bc45"
                        ]=> bool(false)
                    } [
                        2
                    ]=> array(3) {
                        [
                            "field_64dfd8bf4bc43"
                        ]=> string(14) "bay_rider_2260" [
                            "field_64dfd8bf4bc44"
                        ]=> string(14) "BAY RIDER 2260" [
                            "field_64dfd8bf4bc45"
                        ]=> bool(false)
                    } [
                        3
                    ]=> array(3) {
                        [
                            "field_64dfd8bf4bc43"
                        ]=> string(14) "bay_rider_2260" [
                            "field_64dfd8bf4bc44"
                        ]=> string(14) "BAY RIDER 2260" [
                            "field_64dfd8bf4bc45"
                        ]=> bool(false)
                    } [
                        4
                    ]=> array(3) {
                        [
                            "field_64dfd8bf4bc43"
                        ]=> string(14) "bay_rider_2060" [
                            "field_64dfd8bf4bc44"
                        ]=> string(14) "BAY RIDER 2060" [
                            "field_64dfd8bf4bc45"
                        ]=> bool(false)
                    }
                }
            }
        } [
            2
        ]=> array(1) {
            [
                "field_64dfd8bf4bc3e"
            ]=> array(4) {
                [
                    "field_64dfd8bf4bc3f"
                ]=> string(12) "bayrider_bay" [
                    "field_64dfd8bf4bc40"
                ]=> string(13) "Bay Rider Bay" [
                    "field_64dfd8bf4bc41"
                ]=> string(73) "http://kencraftboats.wpdev.me/wp-content/uploads/2023/07/bayrider_bay.jpg" [
                    "field_64dfd8bf4bc42"
                ]=> array(2) {
                    [
                        0
                    ]=> array(3) {
                        [
                            "field_64dfd8bf4bc43"
                        ]=> string(17) "bay_rider_219_bay" [
                            "field_64dfd8bf4bc44"
                        ]=> string(17) "BAY RIDER 219 BAY" [
                            "field_64dfd8bf4bc45"
                        ]=> string(78) "http://kencraftboats.wpdev.me/wp-content/uploads/2023/08/bay_rider_219_bay.jpg"
                    } [
                        1
                    ]=> array(3) {
                        [
                            "field_64dfd8bf4bc43"
                        ]=> string(17) "bay_rider_239_bay" [
                            "field_64dfd8bf4bc44"
                        ]=> string(17) "BAY RIDER 239 BAY" [
                            "field_64dfd8bf4bc45"
                        ]=> string(78) "http://kencraftboats.wpdev.me/wp-content/uploads/2023/08/bay_rider_239_bay.jpg"
                    }
                }
            }
        }
    }
  • John, I actually got this working now.

    // start building this row from sub fields of the main repeater
        while ( have_rows( 'boat_lines', 'option' ) ) : the_row();        
            $line_value = get_sub_field('line_name');
            $line_name = get_sub_field('label');
            $line_image = get_sub_field('image');
            
            $boat_line_repeater_rows = array(
                // add fields of the main repeater
                'field_64dfd8bf4bc3f' => $line_value,
                'field_64dfd8bf4bc40' => $line_name,
                'field_64dfd8bf4bc41' => $line_image,
            );   
    
            // sub repeater        
            if ( have_rows('model') ) {
                // initialize the sub repeater array
                $boat_line_model_repeater_rows = array();
    
                while( have_rows('model') ) : the_row();
                    // Get sub value.
                    $model_value = get_sub_field('value');
                    $model_name = get_sub_field('name');  
                    $model_image = get_sub_field('image');  
                    
                    // add a row to sub repeater array
                    $boat_line_model_repeater_rows[] = array(
                        // add fields from sub repeater
                        'field_64dfd8bf4bc43' => $model_value,
                        'field_64dfd8bf4bc44' => $model_name,
                        'field_64dfd8bf4bc45' => $model_image
                    );
    
                endwhile; // end sub repeater while
    
                // add sub repeater to the current row
                $boat_line_repeater_rows['field_64dfd8bf4bc42'] = $boat_line_model_repeater_rows;
            } // end sub repeater if
    
            // add the new row to the main repeater
            $boat_line_rows[] = array(
                // field key => value pairs for each sub field            
                'field_64dfd8bf4bc3e' => array(
                    $boat_line_repeater_rows
                )
                // next row in nested repeater
            );
    
        endwhile; // end main repeater while 
  • Here is what the logic I have produces:

  • Thanks John, I copied in your example but it still doesn’t seem to be working quite right. I can create correct number of row, but they are empty. Maybe a screenshot would help show what I have?

  • @jgregory we did not figure out a solid migration plan. We found a work around, although I think there should be a better solution, of publishing our clone fields and renaming them the same name as the existing cloned field name. This allowed us to keep the data intact.

    So basically, we had several Field Groups that were a tab layout. To keep the data and have then show in GraphQL, we had to get the existing name of the clone field in the tab, publish the field being used for cloning and rename it to what the field name was in the tab.

    I did come up with some sort of db migration, but it got confusing and I wasn’t the only one working on the project so we ended up scrapping it and going this way, but here is what I came up with if you wanted to go the go the db route.

    For example, to search for Header Secondary you would use:

    SELECT * FROMwp_postmetaWHERE meta_key like '%_header_secondary%'

    this will return all keys for that. But we still need to find the specific one for the field group you are working on. To do that we need to find a post that is using that group and get it’s ID and then we can run:

    SELECT * FROMwp_postmetaWHERE post_id = {id} AND meta_key like '%header_secondary%'

    Now that you have both key and value for a post we can run an update sql statement. There will be 2:

    We are migrating old field name to new field
    UPDATEwp_postmeta` as m
    JOIN wp_posts as p ON m.post_id = p.ID
    SET m.meta_key = ‘new_field_name’
    WHERE m.meta_key = ‘old_field_name’
    AND p.post_type = ‘page’`

    We are migrating old field value to new field name.

    This is how we keep the data this is what is mapped to the wp_posts table
    UPDATE <code>wp_postmeta</code> as m 
    JOIN <code>wp_posts</code> as p ON m.post_id = p.ID 
    SET m.meta_key = '_new_field_name' 
    WHERE m.meta_value = 'field_5af0d933478b4' 
    AND p.post_type = 'page'

    I did run some tests with this and it did work. Depending on how many Fields you have though this could be a long process. I was thinking about maybe righting up a php script that could automate this but I don’t have much time to work on it.

  • I know this is an old post and I have actually submitted a new post https://support.advancedcustomfields.com/forums/topic/using-publish_posttype-to-get-acf-fields/ in regards to using the publish action with custom post type. I am not able to use $_POST to get the acf values and using acf/save_post only get’s acf fields not wordpress fields like post title and post content. Would it be save to assume that I just need replace all of wp fields like the post title and post content editor with an acf fields?

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