acf_shortcode

Acf_shortcode().

Description

acf_shortcode( $atts ); 

This function is used to add basic shortcode support for the ACF plugin

Parameters (1)

0. $atts
The atts.

Usage

  1. if ( !function_exists( 'acf_shortcode' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'advanced-custom-fields/core/api.php'; 
  3.  
  4. // The atts. 
  5. $atts = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = acf_shortcode($atts); 
  9.  

Defined (1)

The function is defined in the following location(s).

/core/api.php  
  1. function acf_shortcode( $atts ) 
  2. // extract attributs 
  3. extract( shortcode_atts( array( 
  4. 'field' => "",  
  5. 'post_id' => false,  
  6. ), $atts ) ); 
  7.  
  8.  
  9. // $field is requird 
  10. if( !$field || $field == "" ) 
  11. return ""; 
  12.  
  13.  
  14. // get value and return it 
  15. $value = get_field( $field, $post_id ); 
  16.  
  17.  
  18. if( is_array($value) ) 
  19. $value = @implode( ', ', $value ); 
  20.  
  21. return $value;