# Custom content in kirbytext

**URL:** <https://forum.getkirby.com/t/custom-content-in-kirbytext/3689>\
**Category:** Questions\
**Tags:** v2\
**Created:** [March 26, 2016, 8:41am UTC](https://forum.getkirby.com/t/custom-content-in-kirbytext/3689 "2016-03-26T08:41:06Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [March 26, 2016, 10:23am UTC](https://forum.getkirby.com/t/custom-content-in-kirbytext/3689/2 "2016-03-26T10:23:22Z")

</div>

Try this:

```auto
<?php

kirbytext::$pre[] = function($kirbytext, $text) {
  $text = preg_replace_callback('!\(centertext(…|\.{3})\)(.*?)\((…|\.{3})centertext\)!is', function($matches) use($kirbytext) {
    $customtext = $matches[2];
    $html = "";
    $field = new Field($kirbytext->field->page, null, trim($customtext));
    $html = '<div class="center">' . $field->kt() . '</div>';
    return $html;
  }, $text);
  return $text;
};

```

---

_[View the full topic](https://forum.getkirby.com/t/custom-content-in-kirbytext/3689)._
