Overview

ACF Field Picker helps you easily add any ACF field to Visual Composer and display it on front-end.

Field Contexts

There are 4 possible contexts to pick a field from:

  1. This page – pick any field and render it on front-end from the current page you’re editing. It can be post or taxonomy term.
  2. Another page – pick any field and render it on front-end from another post or category.
  3. Options – pick any field and render it on front-end from ACF options pages.
  4. Custom – select any field by browsing existing field groups. Extremely useful for creating Master templates.

Example

The post example from the video above you can find here.

Hooks

The values retrieved via ACF Field Picker could be manually adjusted – formatted or replaced. The shortcode allows to hook by:

  1. field type (number, color_picker, visual_composer, etc.)
  2. field name you give while creating field groups (e.g. my_custom_heading)
  3. field key generated by ACF (e.g. field_58c51fbdec9c9)

The execution order and the exact script is:


$result = apply_filters( sprintf( 'vc_acf_field_picker_render_field_type_%s', $field_object[ 'type' ] ), $result, $field_object, $post_id );
$result = apply_filters( sprintf( 'vc_acf_field_picker_render_field_name_%s', $field_object[ 'name' ] ), $result, $field_object, $post_id );
$result = apply_filters( sprintf( 'vc_acf_field_picker_render_field_key_%s', $field_object[ 'key' ] ), $result, $field_object, $post_id );

The plugin comes with the predefined filters:


  add_filter( 'vc_acf_field_picker_render_field_type_password', 'vc_acf_field_picker_render_field_type_password_filter', 10, 3 );
  add_filter( 'vc_acf_field_picker_render_field_type_file', 'vc_acf_field_picker_render_field_type_file_filter', 10, 3 );
  add_filter( 'vc_acf_field_picker_render_field_type_gallery', 'vc_acf_field_picker_render_field_type_gallery_filter', 10, 3 );
  add_filter( 'vc_acf_field_picker_render_field_type_visual_composer', 'vc_acf_field_picker_render_field_type_visual_composer_filter', 10, 3 );
  add_filter( 'vc_acf_field_picker_render_field_type_image', 'vc_acf_field_picker_render_field_type_image_filter', 10, 3 );
  add_filter( 'vc_acf_field_picker_render_field_type_select', 'vc_acf_field_picker_render_field_type_select_filter', 10, 3 );
  add_filter( 'vc_acf_field_picker_render_field_type_radio', 'vc_acf_field_picker_render_field_type_radio_filter', 10, 3 );
  add_filter( 'vc_acf_field_picker_render_field_type_checkbox', 'vc_acf_field_picker_render_field_type_checkbox_filter', 10, 3 );
  add_filter( 'vc_acf_field_picker_render_field_type_true_false', 'vc_acf_field_picker_render_field_type_true_false_filter', 10, 3 );
  add_filter( 'vc_acf_field_picker_render_field_type_post_object', 'vc_acf_field_picker_render_field_type_post_object_filter', 10, 3 );
  add_filter( 'vc_acf_field_picker_render_field_type_page_link', 'vc_acf_field_picker_render_field_type_page_link_filter', 10, 3 );
  add_filter( 'vc_acf_field_picker_render_field_type_email', 'vc_acf_field_picker_render_field_type_email_filter', 10, 3 );
  add_filter( 'vc_acf_field_picker_render_field_type_url', 'vc_acf_field_picker_render_field_type_url_filter', 10, 3 );
  add_filter( 'vc_acf_field_picker_render_field_type_relationship', 'vc_acf_field_picker_render_field_type_relationship_filter', 10, 3 );
  add_filter( 'vc_acf_field_picker_render_field_type_taxonomy', 'vc_acf_field_picker_render_field_type_taxonomy_filter', 10, 3 );
  add_filter( 'vc_acf_field_picker_render_field_type_user', 'vc_acf_field_picker_render_field_type_user_filter', 10, 3 );
  add_filter( 'vc_acf_field_picker_render_field_type_google_map', 'vc_acf_field_picker_render_field_type_google_map_filter', 10, 3 );
  add_filter( 'vc_acf_field_picker_render_field_type_color_picker', 'vc_acf_field_picker_render_field_type_color_picker_filter', 10, 3 );
  add_filter( 'vc_acf_field_picker_render_field_type_repeater', 'vc_acf_field_picker_render_field_type_repeater_filter', 10, 3 );
  add_filter( 'vc_acf_field_picker_render_field_type_flexible_content', 'vc_acf_field_picker_render_field_type_flexible_content_filter', 10, 3 );

If needed, you can disable all filters with the following code from your functions.php:


add_filter( 'vc_acf_field_picker_default_fields_rendering', function( $flag ) { return false; } );

You can remove an existing filter separately, with this code (make sure to adjust the filter and function names):


remove_filter( 'vc_acf_field_picker_render_field_type_password', 'vc_acf_field_picker_render_field_type_password', 10 );

Additionally, you can add your custom filter:


add_filter( 'vc_acf_field_picker_render_field_type_password', function( $value, $field_object, $post_id ) {
  return str_repeat( "x", strlen( $value ) );
}, 10, 3 );

Don't have WP ACF-VC Bridge yet?

Combine the powers of two giants

Get a must have plugin for modern WordPress website today!

0
Comments

Leave a Reply

Your email address will not be published. Required fields are marked *