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

Populate ACF Field with Post Types

function acf_load_post_types_populate_field( $field ) { // reset choices $field[‘choices’] = array(); // Get post types $args = array( ‘public’ => true, ); $post_types = get_post_types( $args, ‘objects’ ); unset( $post_types[‘attachment’] ); foreach ( $post_types as $post_type ) { $value =…Continue reading

Loading ACF Blocks from theme

/** * Load Blocks */ function load_blocks() { $theme = wp_get_theme(); $blocks = get_blocks(); foreach( $blocks as $block ) { if ( file_exists( get_template_directory() . ‘/blocks/’ . $block . ‘/block.json’ ) ) { register_block_type( get_template_directory() . ‘/blocks/’ . $block .…Continue reading

PvR – ACF Extended Bidirectional update Attention: ONLY ONCE

add_action(‘admin_init’, ‘my_acf_update_bidirectional_posts’); function my_acf_update_bidirectional_posts(){ // bail early if ajax request if(wp_doing_ajax()){ return; } // Retrieve all pages $get_posts = get_posts(array( ‘post_type’ => ‘page’, ‘posts_per_page’ => -1, ‘fields’ => ‘ids’, )); // Bail early if not found if(empty($get_posts)){ return; } //…Continue reading