Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add a 'Director: ' label in front of a custom 'director' production field. For use inside the functions.php of your theme.
<?php
/*
* Adds a 'Director: ' label in front of a custom 'director' production field.
* @param string $value The value for the 'director' field.
* @param string $field The custom field name.
* @param WPT_Production $production The production.
* @return string The updated value for the 'director' field.
*/
function wpt_add_director_label($value, $field, $production) {
if (!empty($value)) {
$value = 'Director: '.$value;
}
return $value;
}
add_filter('wpt_production_director', 'wpt_add_director_label', 10, 3);
@slimndap
Copy link
Author

slimndap commented Oct 22, 2015

When using a plugin like Simple Fields, the custom field names may look different (eg. _simple_fields_fieldGroupID_1_fieldID_1_numInSet_0). In that case the code looks like this:

<?php
  /*
   * Adds a 'Director: ' label in front of a custom 'director' production field.
   * @param   string          $value      The value for the 'director' field.
   * @param   string          $field      The custom field name.
   * @param   WPT_Production  $production The production.
   * @return  string                      The updated value for the 'director' field.
   */
  function wpt_add_director_label($value, $field, $production) {
    if (!empty($value)) {
      $value = 'Director: '.$value;
    }
    return $value;
  }
  add_filter('wpt_production__simple_fields_fieldGroupID_1_fieldID_1_numInSet_0', 'wpt_add_director_label', 10, 3);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment