ProcessWire
Recipes_

Create page via API

Problem

You want to create one or more pages, bypassing the admin interface

Solution

$p = new Page();
$p->setOutputFormatting(false);
$p->template = 'products'; // example template
$p->parent = wire('pages')->get('/'); // example parent
$p->name = "foo"; // example name
$p->title = "My API-generated new PW page";
$p->fieldname = "my field value"; // example field with example value
$p->save();
echo "page ID {$p->id} created!<br>";

Resources