Classic functions
These are the ACF-style functions, and they all keep working. If you are moving a project across, they are the shortest route: the names map one to one onto the ACF ones you already have in your templates.
For new work, the Template API says the same thing in less code. Writing values still goes through the functions on this page.
Reference#
| Function | Signature |
|---|---|
| Get a value | ultivo_get_field( string $selector, $post_id = false, bool $format_value = true ) |
| Echo a value | ultivo_the_field( string $selector, $post_id = false ): void |
| Get all values | ultivo_get_fields( $post_id = false ): array |
| Get field + value | ultivo_get_field_object( string $selector, $post_id = false, bool $format_value = true ) |
| Update a value | ultivo_update_field( string $selector, $value, $post_id = false ): bool |
| Delete a value | ultivo_delete_field( string $selector, $post_id = false ): bool |
| Add a repeater row | ultivo_add_row( string $selector, array $row, $post_id = false ) |
| Start/continue a loop | ultivo_have_rows( string $selector, $post_id = false ): bool |
| Advance to the next row | ultivo_the_row() |
| Current row index | ultivo_get_row_index(): int |
| Current row's layout | ultivo_get_row_layout() |
| Sub-field value | ultivo_get_sub_field( string $selector, bool $format_value = true ) |
| Echo a sub-field | ultivo_the_sub_field( string $selector ): void |
ultivo_get_field()#
The core read function. $selector is the field name (or key); $post_id defaults to the current post. $format_value controls whether the value is formatted for display (an image field, for example, returns an array with url, alt, width, height) or returned raw.
$title = ultivo_get_field( 'hero_title' ); $title = ultivo_get_field( 'hero_title', 12 ); $raw = ultivo_get_field( 'price', false, false );
If the selector doesn't match any known field, ultivo_get_field() falls back to the raw post meta value for that key (the same behavior ACF has) and returns null if no meta exists either.
ultivo_the_field()#
Echoes a field's value directly, escaped through wp_kses_post() so basic HTML in text/textarea/WYSIWYG fields survives while scripts don't. Arrays and objects (image fields, repeaters) are silently skipped. Use ultivo_get_field() for those.
<h1><?php ultivo_the_field( 'hero_title' ); ?></h1>
ultivo_get_fields()#
Returns every top-level field for a post (or user/term/options context) as an associative array, keyed by field name. Useful for dumping a full set of values without naming each one.
$fields = ultivo_get_fields(); // [ 'hero_title' => 'Welcome', 'hero_subtitle' => '...', ... ]
ultivo_get_field_object()#
Returns the field's full definition (label, type, instructions, choices, and so on) with the current value merged in under value. Useful for building admin tooling or generic renderers that need more than just the value.
$field = ultivo_get_field_object( 'hero_title' ); echo $field['label']; // "Hero title" echo $field['value']; // "Welcome"
Writing values#
ultivo_update_field() and ultivo_delete_field() write and remove a value. For a selector with no matching field definition, they fall back to plain post meta, so both work against arbitrary meta keys too.
ultivo_update_field( 'hero_title', 'New title', 12 ); ultivo_delete_field( 'hero_title', 12 );
ultivo_add_row() appends a row to a repeater, keyed by sub-field name, and returns the new row count (or false if the selector isn't a repeater):
ultivo_add_row( 'team', [ 'name' => 'Jane' ] );
The classic loop#
ultivo_have_rows() / ultivo_the_row() work exactly like their ACF counterparts, including support for nested repeaters and flexible content inside the loop:
if ( ultivo_have_rows( 'team' ) ) : while ( ultivo_have_rows( 'team' ) ) : ultivo_the_row(); $name = ultivo_get_sub_field( 'name' ); ultivo_the_sub_field( 'bio' ); endwhile; endif;
ultivo_get_row_index() returns the zero-based index of the current row; ultivo_get_row_layout() returns the current row's layout name inside a flexible content loop. See the Template API for a shorter alternative to this loop.
The $post_id argument#
Every read/write function accepts a $post_id argument that targets more than just posts:
false: the current post (the default).- An integer or
WP_Postobject: that specific post. "user_5": user ID 5."term_9"(or"category_9"): term ID 9."option"or"options": the default options page.- Any other string: treated as a custom options prefix.
$bio = ultivo_get_field( 'bio', 'user_5' ); $name = ultivo_get_field( 'name', 'term_9' ); $logo = ultivo_get_field( 'logo', 'options' );