Reference

Guide

$page->increment()

Increment a given field value

$page->increment(string $field, int $by = 1, int $max = null): Kirby\Cms\Page

Parameters

Name Type Default Description
$field string
$by int 1
$max int null

Return type

Kirby\Cms\Page

Example

<?php $page->increment('likes') ?>

Notice

The increment method will only work reliably with field values that PHP can parse into a valid integer. Otherwise the field value will be evaluated as zero and incremented to 1 or whatever $by value you pass.

Inherited from

Kirby\Cms\ModelWithContent

Source code

kirby/src/Cms/ModelWithContent.php#L214