Created
March 4, 2018 15:10
-
-
Save psaikali/7bf9d9ddcd4866849a571872649b094c to your computer and use it in GitHub Desktop.
Remplacer des variables/placeholders dans les champs ACF de type Message
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Article/tutoriel complet sur https://mosaika.fr/astuces-developpement-acf/ | |
// Documentation officielle https://www.advancedcustomfields.com/resources/acf-load_field/ | |
/** | |
* Injecter des données dynamiques dans les champs de type message | |
* Filtre : acf/load_field | |
*/ | |
function msk_acf_variables_in_message_fields($field) { | |
$field['message'] = str_replace( | |
['%date_debut%', '%date_fin%'], | |
[date('Y') - 5, date('Y')], | |
$field['message'] | |
); | |
return $field; | |
} | |
add_filter('acf/load_field/type=message', 'msk_acf_variables_in_message_fields'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment