PagesVersions::addPageVersion() method

Add a new page version and return the added version number

Example

$page = $pages->get(1234);
$version = $pagesVersions->addPageVersion($page);
echo "Added version $version for page $page";

Usage

// basic usage
$int = $pagesVersions->addPageVersion(Page $page);

// usage with all arguments
$int = $pagesVersions->addPageVersion(Page $page, array $options = []);

Arguments

NameType(s)Description
pagePage
options (optional)array
  • description (string): Optional text description for version.
  • names (array): Names of fields/properties to include in the version or omit for all.

Return value

int

Version number or 0 if no version created

Exceptions

Method can throw exceptions on error:

  • WireException or \PDOException


$pagesVersions methods and properties

API reference based on ProcessWire core version 3.0.248

Latest news

  • ProcessWire Weekly #582
    The 582nd issue of ProcessWire Weekly brings in all the latest news from the ProcessWire community. Modules, sites, and more. Read on!
    Weekly.pw / 5 July 2025
  • New ProcessWire admin redesign
    When you upgrade to ProcessWire 3.0.248 or newer (currently the dev branch), you’ll immediately notice something new and beautiful…
    Blog / 9 May 2025
  • Subscribe to weekly ProcessWire news

“ProcessWire is like a breath of fresh air. So powerful yet simple to build with and customise, and web editors love it too.” —Margaret Chatwin, Web developer