Title: Insert ACF as Function
Last modified: October 25, 2020

---

# Insert ACF as Function

 *  Resolved [Afrancel](https://wordpress.org/support/users/bcreativos/)
 * (@bcreativos)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/insert-acf-as-function/)
 * Hi, hope you’re fine.
    Could you help me how can I convert this to a function.
   I need insert this custom field in Single product of woocommerce, but I would
   like to do it trhought functions.
 * ******
    <?php $link = get_field( ‘link’ ); ?> <?php if ( $link ) : ?> “><?php
   echo esc_html( $link ); ?> <?php endif; ?>
 * ******
    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [samjco](https://wordpress.org/support/users/samjco/)
 * (@samjco)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/insert-acf-as-function/#post-13599958)
 * Just export the PHP of the ACF field group and add to your functions.php
    [https://www.advancedcustomfields.com/resources/register-fields-via-php/](https://www.advancedcustomfields.com/resources/register-fields-via-php/)
 *  Plugin Author [Konrad Chmielewski](https://wordpress.org/support/users/hwk-fr/)
 * (@hwk-fr)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/insert-acf-as-function/#post-13601282)
 * Hello,
 * Thanks for the feedback. Sorry for the late answer, I was very busy with ACF 
   Extended Pro lately.
 * I’m not sure to correctly understand your question tho. It looks like it’s related
   to general PHP/WordPress/Woocommerce development.
 * You can simply create a function that echo your data. Example:
 *     ```
       function my_function(){
   
           $link = get_field('link');
   
           if($link){
                echo esc_html($link);
           }
   
       }
       ```
   
 * Regards.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Insert ACF as Function’ is closed to new replies.

 * ![](https://ps.w.org/acf-extended/assets/icon-256x256.png?rev=2071550)
 * [Advanced Custom Fields: Extended](https://wordpress.org/plugins/acf-extended/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/acf-extended/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/acf-extended/)
 * [Active Topics](https://wordpress.org/support/plugin/acf-extended/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/acf-extended/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/acf-extended/reviews/)

 * 2 replies
 * 3 participants
 * Last reply from: [Konrad Chmielewski](https://wordpress.org/support/users/hwk-fr/)
 * Last activity: [5 years, 6 months ago](https://wordpress.org/support/topic/insert-acf-as-function/#post-13601282)
 * Status: resolved