Uyumadan önce taze taze, iyi geceler.
// Oluşturma Sayfasına Ekle
add_action( 'category_add_form_fields', 'add_category_field', 10, 2 );
function add_category_field( $taxonomy ) { ?>
<div class="form-field term-group">
<label for="category-custom-description">Açıklama</label>
<textarea rows="5" id="category-custom-description" name="category-custom-description"></textarea>
</div>
<?php }
// Oluşturma Sayfasında Güncelleme
add_action( 'created_category', 'save_category_field', 10, 2 );
function save_category_field ( $term_id, $tt_id ) {
if( isset( $_POST['category-custom-description'] ) && '' !== $_POST['category-custom-description'] ){
$posts = $_POST['category-custom-description'];
add_term_meta( $term_id, 'category-custom-description', $posts, true );
}
}
// Düzenleme Sayfasına Ekle
add_action( 'category_edit_form_fields', 'edit_category_fields', 10, 2 );
function edit_category_fields($term, $taxonomy ) {
$description = get_term_meta( $term->term_id, 'category-custom-description', true );
?>
<tr class="form-field">
<th scope="row"><label for="category-custom-description">Açıklama</label></th>
<td>
<textarea row="5" name="category-custom-description" id="category-custom-description"><?php echo $description; ?></textarea>
</td>
</tr>
<?php }
// Düzenleme Sayfasında Güncelleme
add_action( 'edited_category', 'updated_category_fields', 10, 2 );
function updated_category_fields ( $term_id, $tt_id ) {
if( isset( $_POST['category-custom-description'] ) && '' !== $_POST['category-custom-description'] ){
$description = $_POST['category-custom-description'];
update_term_meta ( $term_id, 'category-custom-description', $description );
} else {
update_term_meta ( $term_id, 'category-custom-description', '' );
}
}https://gist.github.com/cagriuckan/34b1a699c4cd103cbef8585ad0aa0f61