gpt-3.5-turbo-0613· openai
Suzhen/CodeChat
اريد كود لاصلاح خطأ في ووردبريس لصورة Featured Image المنتج “role=“presentation””
- User
اريد كود لاصلاح خطأ في ووردبريس لصورة Featured Image المنتج “role=“presentation””
- Assistant
يمكنك استخدام الكود التالي لإزالة الخاصية "role=“presentation”" من صورة Featured Image في ووردبريس:
function remove_featured_image_role_attribute( $html, $post_id, $post_image_id ) { $html = preg_replace( '/\s*role="presentation"/', '', $html ); return $html; } add_filter( 'post_thumbnail_html', 'remove_featured_image_role_attribute', 10, 3 );قم بإضافة هذا الكود إلى ملف functions.php في مجلد نشاط القالب الخاص بك في ووردبريس. بعد حفظ التغييرات وإعادة تحميل موقعك، يجب أن تتمكن من رؤية تغيير في عنصر HTML الذي يُنشئ لصورة Featured Image، حيث سيتم إزالة خاصية "role=“presentation”".