Tự động thêm thẻ alt, title khi upload hình ảnh lên Website WordPress là thủ thuật rất cần thiết khi thiết kế wordpress. Khi upload và chèn hình ảnh vào bài viết sẻ có một số thông số bạn cần nhập vào để hỗ trợ cho SEO tốt hơn (alt, caption, title) nhưng mặc định WordPress sẻ không tự thêm vào alt, caption, description mà bạn phải nhập vào thủ công, tất nhiên ngồi nhập cũng được nhưng nếu bạn gặp phải một số dự án với quá nhiều hình ảnh thì việc này sẻ hơi bất tiện hoặc đơn giản nếu bạn cấu hình WordPress cho một ai đó mà họ không rành về SEO thì nên sử dụng thủ thuật để khi upload ảnh vào bài viết nó tự động thêm vào caption, alt hoặc title thì sẻ hoàn hảo hơn
Nếu bạn đang tìm kiếm giải pháp để làm việc này thì bài viết này Zubi Cloud sẽ giúp ích cho bạn đấy, khi upload hình ảnh vào bài viết nó sẻ tự động thêm vào alt, caption, title hình ảnh đầy đủ.
Rất đơn giản, chỉ cần chèn đoạn code sau vào file funtions.php
/* Tự động thêm Title, Alt-Text, Caption & Description cho hình ảnh --------------------------------------------------------------------------------------*/ add_action( 'add_attachment', 'ttv_set_image_meta_image_upload' ); function ttv_set_image_meta_image_upload( $post_ID ) { // Check if uploaded file is an image, else do nothing if ( wp_attachment_is_image( $post_ID ) ) { $my_image_title = get_post( $post_ID )->post_title; // Sanitize the title: capitalize first letter of every word (other letters lower case): $my_image_title = ucwords( strtolower( $my_image_title ) ); // Create an array with the image meta (Title, Caption, Description) to be updated // Note: comment out the Excerpt/Caption or Content/Description lines if not needed $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) 'post_content' => $my_image_title, // Set image Description (Content) ); // Set the image Alt-Text update_post_meta( $post_ID, '_wp_attachment_image_alt', $my_image_title ); // Set the image meta (e.g. Title, Excerpt, Content) wp_update_post( $my_image_meta ); } }
Khi thêm đoạn code trên vào thì khi upload bất cứ hình ảnh nào lên WordPress thì nó sẻ tự động cập nhật title, caption, mô tả và alt cho hình ảnh dựa vào tên ảnh mà bạn đặt. Zubi Cloud luôn cố gắng đưa ra nhiều thủ thuật thiết kế Website bằng WordPress, hy vọng sẽ giúp quý khách hàng tốt nhất để có được 1 website chuyên nghiệp mang lại hiệu quả kinh doanh online.
how much does zyprexa cost
Get Paid to Play Games in Kenya
best online casino games kenya [url=https://levine.co.ke/best-online-games-that-pay-real-money-in-kenya]games that pay real money in kenya[/url] .
zyprexa 2.5
zyprexa iv
why does zyprexa cause weight gain
zofran shelf life
batmanapollo.ru
zofran pregnancy risks
purchase lamisil online – purchase griseofulvin for sale buy griseofulvin tablets
what is stronger zofran or phenergan
zyprexa for agitation
discount wellbutrin sr
rybelsus cheap – semaglutide 14 mg without prescription buy generic DDAVP online
zetia patent expires
what are the most common side effects of zyprexa?
zofran pump pregnancy