Functions.php dosyasını bir metin editörü ile açıyoruz, (ben notepaad programı kullanıyorum) dosyanın en altına php> tagı kapanmadan önce aşağıdaki kodu ekliyoruz.
//Resim Alt Etiket Kod başlangıcı
add_action( 'add_attachment', 'my_set_image_meta_upon_image_upload' );
function my_set_image_meta_upon_image_upload( $post_ID ) {
if ( wp_attachment_is_image( $post_ID ) ) {
$my_image_title = get_post( $post_ID )->post_title;
$my_image_title = preg_replace( '%\s*[-_\s]+\s*%', ' ', $my_image_title );
$my_image_title = ucwords( strtolower( $my_image_title ) );
$my_image_meta = array(
'ID' => $post_ID, // Specify the image (ID) to be updated
'post_title' => $my_image_title, // Set image Title to sanitized title
'post_excerpt' => $my_image_title, // Set image Caption (Excerpt) to sanitized title
'post_content' => $my_image_title, // Set image Description (Content) to sanitized title
);
update_post_meta( $post_ID, '_wp_attachment_image_alt', $my_image_title );
wp_update_post( $my_image_meta );
}
}
//Resim alt etiket kod bitiş