• alaron

    (@alaron)


    <font style=”vertical-align: inherit;”><font style=”vertical-align: inherit;”>Давним-давно я пол?нувався написати скрипт, щоб в?н автоматично вставляв заголовок поста як альтернативне зображення в цей пост. Можливо, я б так ? зробив, якби цей плаг?н не попався мен? на оч?. Але зараз я пом?тив, що ця функц?я стала платною. Ви жарту?те? Вам не потр?бно бути технолог?чним гуру, щоб робити це без плаг?на. Дякую тоб?!</font></font>

    Next code lines will do the same in your functions.php (save 8$ per month Jesus!!!):

    function replace_empty_alt_tags_with_post_title($attr, $attachment, $size) {
         // Check if the alt attribute is empty
         if (empty($attr['alt'])) {
             // Get the ID of the post to which the image is attached
             $post_id = $attachment->post_parent;
            
             // Get the post title
             $post_title = get_the_title($post_id);
            
             // If there is a title, replace the empty alt with the post title
             if ($post_title) {
                 $attr['alt'] = $post_title;
             }
         }
        
         return $attr;
    }
    • This topic was modified 10 months ago by alaron.
  • The topic ‘Thirst for profit’ is closed to new replies.