Doplňuje vlastní term meta pro rubriku/štítek.
<?php
function gog_vyrobce_custom_fields($taxonomy) {
$tax_id = $taxonomy->term_id;
$vyrobce_short = get_term_meta($tax_id, 'vyrobce_short', true);
?>
<tr class="form-field">
<th scope="row" valign="top">
<label for="vyrobce_short">Zkrácený název</label>
</th>
<td>
<input type="text" name="vyrobce_short" id="vyrobce_short" style="width:100%;" value="<?php echo $vyrobce_short ? $vyrobce_short : ''; ?>">
<p class="description">Zobrazuje se v detailu příspěvku</p>
</td>
</tr>
<?php
}
add_action('vyrobce_edit_form_fields', 'gog_vyrobce_custom_fields');
function gog_save_vyrobce_custom_fields($term_id) {
if (isset($_POST['vyrobce_short'])) {
$vyrobce_short = sanitize_text_field($_POST['vyrobce_short']);
update_term_meta($term_id, 'vyrobce_short', $vyrobce_short);
}
}
add_action('edited_vyrobce', 'gog_save_vyrobce_custom_fields', 10, 1);