Skip to content

Instantly share code, notes, and snippets.

View yehudah's full-sized avatar

Yehuda Hassine yehudah

View GitHub Profile
@yehudah
yehudah / acf-get-field-key.php
Created December 10, 2015 09:12 — forked from mcguffin/acf-get-field-key.php
WordPress Advanced Custom Fields get field key from field name
<?php
/**
* Get field key for field name.
* Will return first matched acf field key for a give field name.
*
* ACF somehow requires a field key, where a sane developer would prefer a human readable field name.
* http://www.advancedcustomfields.com/resources/update_field/#field_key-vs%20field_name
*
* This function will return the field_key of a certain field.
/**
* Add the field to order emails
**/
add_filter('woocommerce_email_order_meta_keys', 'my_custom_checkout_field_order_meta_keys');
function my_custom_checkout_field_order_meta_keys( $keys ) {
$keys[‘My Field 1′] = ‘_my_field_1;
$keys[‘My Field 2′] = ‘_my_field_2′;
return $keys;
}