37. Migrating from Meta Box | Field Forge - Custom Fields, Built for Speed
Download Log in

37. Migrating from Meta Box

Developer Guide

If your site uses Meta Box for custom fields, Field Forge can cover a manual/beta migration path. Meta Box stores many values in wp_postmeta using standard meta_key/meta_value pairs, but extension metadata, builder-defined groups, location rules, and custom callbacks must be verified per site before claiming a full one-click migration.

Detection

php
// Check for Meta Box data in postmeta
global $wpdb;
$meta_box_groups = $wpdb->get_results(
    "SELECT DISTINCT meta_key FROM {$wpdb->postmeta}
     WHERE meta_key NOT LIKE '_%'
     AND meta_key NOT LIKE 'field_%'
     ORDER BY meta_key"
);

Migration Strategy

  1. Create matching field groups in Field Forge with the same field names.
  2. Migrate values from wp_postmeta to the Field Forge values table.
  3. Test templates — since Field Forge supports get_field(), update any rwmb_meta() calls.
php
// Batch migrate Meta Box values to Field Forge
function migrate_meta_box_to_fieldforge( $post_type, $field_names ) {
    $posts = get_posts( [ 'post_type' => $post_type, 'numberposts' => -1, 'fields' => 'ids' ] );

    foreach ( $posts as $post_id ) {
        foreach ( $field_names as $name ) {
            $value = get_post_meta( $post_id, $name, true );
            if ( '' !== $value && null !== $value ) {
                update_field( $name, $value, $post_id );
            }
        }
    }
}

// Usage
migrate_meta_box_to_fieldforge( 'product', [ 'price', 'sku', 'description', 'gallery' ] );

Template Updates

Replace Meta Box function calls with Field Forge equivalents:

php
// Before (Meta Box)
$value = rwmb_meta( 'price' );
$images = rwmb_meta( 'gallery', [ 'size' => 'large' ] );

// After (Field Forge)
$value = get_field( 'price' );
$images = get_field( 'gallery' ); // Returns array based on return_format

Forge AI Assistant Online

Hi! I'm the Field Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs