ACF Field Shortcode

function acf_field_shortcode($atts) { $atts = shortcode_atts(array( ‘field’ => ”, ‘post_id’ => false, ), $atts, ‘acf’); if (function_exists(‘get_field’)) { $field_value = get_field($atts[‘field’], $atts[‘post_id’]); // If the field is an array (like a select, relationship, or taxonomy field) if (is_array($field_value)) { $output…Continue reading

Save Options Page Top-Bar Settings to Global Header Section Post

if (!defined(‘ABSPATH’)) exit; define(‘TARGET_POST_ID’, 7183); // Specify the post ID of the layout section that should receive the values add_action(‘acf/save_post’, function ($post_id) { if ($post_id !== ‘options’) { return; } $enabled = get_field(‘enable_header_top-bar’, ‘option’) ? ‘1’ : ”; // specify…Continue reading

Calcula o Progresso de uma Etapa, baseado em suas tarefas

function calcular_valor_do_repeater_acf( $post_id ) { $etapas = ‘etapas’; $tarefas = ‘tarefas’; $checkbox = ‘feito’; $progresso_etapa = ‘progresso_da_etapa’; $progresso_projeto = ‘progresso_do_projeto’; // Check rows exists. if( have_rows($etapas) ): $rows_etapas = 0; $progress_etapas = 0; while( have_rows($etapas) ) : the_row(); // Loop…Continue reading

Add ‘Logged-In Admin’ Rule Option to ACF Pro

// 1. Register the rule under the ‘User’ group add_filter(‘acf/location/rule_types’, function($choices) { $choices[‘User’][‘logged_in_admin’] = ‘Logged-In Admin’; return $choices; }); // 2. Limit to only valid operators for dropdown-based values add_filter(‘acf/location/rule_operators/logged_in_admin’, function($choices) { return [ ‘==’ => ‘is equal to’, ‘!=’…Continue reading

ACF Image Upload Size Restrictions

//add_filter(‘wp_handle_upload_prefilter’,’tps_validate_image_size’); add_filter(‘acf/validate_attachment/name=gallery_post_featured_image’, ‘tps_validate_gallery_image_size’, 10, 5); function tps_validate_gallery_image_size( $errors, $file, $attachment, $field, $context ){ $image_type = $file[‘type’]; $image_filesize = $file[‘size’]; $image_width = $file[‘width’]; $image_height = $file[‘height’]; if ( ( $image_type != ‘jpg’ ) && ( $image_type != ‘jpeg’ ) && (…Continue reading

jQ-ACF-AF Scripts and Styles Dequeue

function shoutout_remove_default_styles() { // Remove default Advanced Forms styles wp_dequeue_style( ‘af-form-style’ ); // Remove default ACF styles wp_dequeue_style( ‘acf-input’ ); wp_dequeue_style( ‘acf-pro-input’ ); // Remove default ACFE styles wp_dequeue_style( ‘acf-extended’ ); wp_dequeue_style( ‘acf-extended-input’ ); wp_dequeue_style( ‘acf-extended-pro-input’ ); } add_action( ‘af/form/enqueue/key=form_64d4c0621a9c5’,…Continue reading

Enable ACF Theme Options Page

if (function_exists(‘acf_add_options_page’)) { acf_add_options_page(array( ‘page_title’ => ‘Theme General Settings’, ‘menu_title’ => ‘Theme Settings’, ‘menu_slug’ => ‘theme-general-settings’, ‘capability’ => ‘edit_posts’, ‘redirect’ => false )); }Continue reading