$page->increment($field, $by = 1, $max = null)

Increment a field value by one or a given value

  • since: Kirby 2.3.0
  • $field (string)
    A field name
  • $by (integer)
    An integer by which to increment
  • $max (integer)
    The max number
  • return ($page)


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


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.

Is something missing or incorrect? Edit this page on Github…