Field Forge підтримує 32 типи полів у 7 категоріях. Цей розділ охоплює прості рядкові та числові поля.
Текст
Зберігає рядок в один рядок. Підтримує налаштування maxlength, placeholder, prepend та append.
php
$value = get_field( 'headline' );
// Returns: 'Welcome to our site'
echo '<h1>' . esc_html( $value ) . '</h1>';
// With prepend/append configured in the admin (e.g., prepend = '$')
// The prepend/append is UI-only; the stored value is the raw input
$price = get_field( 'price_display' );
echo '<span class="price">$' . esc_html( $price ) . '</span>';
// Using text field as a CSS class
$layout = get_field( 'layout_class' );
echo '<div class="section ' . esc_attr( $layout ) . '">Content</div>';Текстова область
Багаторядковий текст з налаштовуваним обробленням переносу рядків.
php
// new_lines setting controls output:
// 'wpautop' wraps in <p> tags
// 'br' converts newlines to <br>
// '' returns raw text with \n characters
$value = get_field( 'description' );
echo $value; // Already formatted based on new_lines setting
// When using raw mode (new_lines = ''), format manually
$raw = get_field( 'notes' );
echo '<pre>' . esc_html( $raw ) . '</pre>';
// Truncate textarea for card displays
$desc = get_field( 'description' );
$short = wp_trim_words( wp_strip_all_tags( $desc ), 20, '...' );
echo '<p class="card-excerpt">' . esc_html( $short ) . '</p>';Число
Числове значення з необов’язковими min, max та step.
php
$value = get_field( 'price' );
// Returns: float when the field has decimals (or the stored value contains a dot)
// int otherwise. Examples: 29.99, 42, 0
// Type-casting in templates is no longer required, but defensive (float)/(int)
// casts are harmless if you prefer them.
echo '$' . number_format( $value, 2 );
// Use in calculations
$price = get_field( 'price' );
$discount = get_field( 'discount_percent' );
$final = $price * ( 1 - $discount / 100 );
echo '<p class="price">$' . number_format( $final, 2 ) . '</p>';
// Conditional rendering based on number
$stock = get_field( 'stock_quantity' );
if ( $stock > 0 ) {
echo '<span class="in-stock">In Stock (' . $stock . ')</span>';
} else {
echo '<span class="out-of-stock">Out of Stock</span>';
}Діапазон
Слайдер, який повертає числове значення.
php
$value = get_field( 'opacity' );
// Returns: int by default (e.g. 75), float if the slider step contains decimals.
echo '<div style="opacity: ' . esc_attr( $value / 100 ) . ';">Content</div>';
// Use range for grid columns
$columns = get_field( 'grid_columns' );
echo '<div class="grid" style="grid-template-columns: repeat(' . $columns . ', 1fr);">';Зберігає перевірений рядок електронної адреси.
php
$email = get_field( 'contact_email' );
// Returns: '[email protected]'
echo '<a href="mailto:' . esc_attr( $email ) . '">' . esc_html( $email ) . '</a>';
// Obfuscate email for spam protection
$email = get_field( 'contact_email' );
echo '<a href="mailto:' . antispambot( $email ) . '">' . antispambot( $email ) . '</a>';URL
Зберігає перевірений рядок URL.
php
$url = get_field( 'website' );
// Returns: 'https://example.com'
echo '<a href="' . esc_url( $url ) . '" target="_blank" rel="noopener">Visit Site</a>';
// External link with icon
$url = get_field( 'documentation_url' );
if ( $url ) {
echo '<a href="' . esc_url( $url ) . '" class="external-link" target="_blank" rel="noopener">';
echo 'View Documentation <span class="icon-external"></span>';
echo '</a>';
}Пароль
Зберігає рядок у звичайному тексті. Не зашифровано в спокої — використовуйте обережно.
php
$pass = get_field( 'api_key' );
// Returns: raw string (stored as plain text)
// Use this type cautiously; not encrypted at rest
// Consider using the fieldforge/load_value filter to decrypt sensitive values—