Manage Field Forge data from the command line using wp eval.
Export All Field Groups to JSON
bash
wp eval 'echo FIELDFORGE_Local_JSON::instance()->save_all();'Check Sync Status
bash
wp eval '$d = FIELDFORGE_Local_JSON::instance()->get_diff(); print_r($d);'Force Sync from JSON to DB
bash
wp eval 'FIELDFORGE_Local_JSON::instance()->sync("json_to_db");'List All Field Groups
bash
wp eval '
$groups = FIELDFORGE_Field_Groups::instance()->get_all();
foreach ( $groups as $g ) {
$fields = json_decode( $g->fields, true );
printf( "#%d: %s (%d fields)n", $g->id, $g->title, count( $fields ) );
}
'Get Field Values for a Post
bash
wp eval '
$fields = get_fields( 42 );
foreach ( $fields as $name => $value ) {
printf( "%s = %sn", $name, is_array( $value ) ? json_encode( $value ) : $value );
}
'Bulk Update Field Values
bash
wp eval '
$posts = get_posts( [ "post_type" => "product", "numberposts" => -1, "fields" => "ids" ] );
foreach ( $posts as $id ) {
$price = (float) get_field( "price", $id );
update_field( "price", $price * 1.1, $id );
}
echo count( $posts ) . " products updated.n";
'Run ACF Migration
bash
wp eval '
$imp = FIELDFORGE_ACF_Import::instance();
$det = $imp->detect();
printf( "Found: %d groups, %d fields, %d postsn", $det["groups"], $det["fields"], $det["posts_with_values"] );
$res = $imp->import_groups();
printf( "Migrated: %d groups, %d errorsn", $res["migrated"], $res["errors"] );
'Flush Field Forge Cache
bash
wp eval 'FIELDFORGE_Performance::instance()->flush_all(); echo "Cache flushed.n";'—