Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 如何从Wordpress 3.5上传中清除默认附件标题?_Image_Wordpress_Attachment_Uploader_Wordpress 3.5 - Fatal编程技术网

Image 如何从Wordpress 3.5上传中清除默认附件标题?

Image 如何从Wordpress 3.5上传中清除默认附件标题?,image,wordpress,attachment,uploader,wordpress-3.5,Image,Wordpress,Attachment,Uploader,Wordpress 3.5,我想在上载新图像时清除图像标题中的默认“文件名”。我尝试使用下面的代码,但没有成功 add_action( 'add_attachment', 'my_upload_title', 99 ); function my_upload_title( $attachment_ID ) { $the_post = array(); $the_post['ID'] = $attachment_ID; $the_post['post_t

我想在上载新图像时清除图像标题中的默认“文件名”。我尝试使用下面的代码,但没有成功

    add_action( 'add_attachment', 'my_upload_title', 99 );
        function my_upload_title( $attachment_ID ) {
        $the_post = array();
        $the_post['ID'] = $attachment_ID;
        $the_post['post_title'] = '';
        wp_update_post( $the_post );    
    }
首先检查,或者您也可以尝试以下代码片段(将代码粘贴到
functions.php
文件中)


感谢您的快速回复@Shiekh Heera!不幸的是,这两个答案在WP 3.5中似乎都不起作用。有趣的是,有一个“更新选项”功能用于图像对齐、链接类型和大小。
add_filter( 'wp_get_attachment_image_attributes', 'remove_image_text');
function remove_image_text( $attr ) {
    unset($attr['alt']);
    unset($attr['title']);
    return $attr;
}