Quick start
1. Create a field group#
In the admin, go to Custom Fields → Add New. Give the group a title and add a couple of fields, for example a text field named hero_title and an image field named hero_image. Under Location, add the rule Post type = Page so the group shows up on pages.
2. Fill in the fields#
Open a page and edit it. The fields you just defined appear as a metabox below the editor. Fill them in and update the page.
3. Print values in your template#
<h1><?php echo esc_html( ultivo_field( 'hero_title' ) ); ?></h1> <?php $image = ultivo_field( 'hero_image' ); ?> <img src="<?php echo esc_url( $image['url'] ); ?>" alt="<?php echo esc_attr( $image['alt'] ); ?>">
A third argument is the value to fall back on when the field is empty:
<h1><?php echo esc_html( ultivo_field( 'hero_title', false, 'Welcome' ) ); ?></h1>
Coming from ACF, ultivo_get_field() does the same thing under the name you already know. See Classic functions.
Next steps#
- Builder basics: everything the field group builder can do
- Template API: the
ultivo_field()/ultivo_rows()syntax used above, including loops - Classic functions: the full
ultivo_get_field()family, for projects moving across from ACF