acf_update_metaref()
acf_update_metaref
Updates reference metadata in the database.
Хуков нет.
Возвращает
(int|true|false)
. Meta ID if the key didn't exist, true on successful update, false on failure.
Использование
acf_update_metaref( $post_id, $type, $references );
- $post_id((int|string))
- The post id.
- $type **
- -
По умолчанию: 'fields' - $references(массив)
- An array of references.
По умолчанию: array()
Список изменений
С версии 5.2.3 | Введена. |
Код acf_update_metaref() acf update metaref ACF 6.0.4
function acf_update_metaref( $post_id = 0, $type = 'fields', $references = array() ) { // Get current references. $current = acf_get_metaref( $post_id, $type ); // Merge in new references. $references = array_merge( $current, $references ); // Simplify groups if ( $type === 'groups' ) { $references = array_values( $references ); } // Remove duplicate references. $references = array_unique( $references ); // Update metadata. return acf_update_metadata( $post_id, "_acf_$type", $references ); }