快捷键(&A);将标题设置为标题的错误方法是使用SQL(未测试):
UPDATE wp_posts
SET post_excerpt = post_title
WHERE
post_excerpt = \'\'
AND post_type = \'attachment\'
AND post_status = \'inherit\'
AND post_mime_type = \'image/jpeg\'
AND ID = 123
这里,我们将ID为的jpeg图像作为目标
123
和空标题。
注:我添加了ID = 123
和post_mime_type = \'image/jpeg\'
作为测试时可以调整的额外限制。还请记住调整的表名wp_posts
.
警告:测试前备份数据库!
如果你在寻找一种动态的方式my answer 这可能与此有关。
您也可以在上载图像时添加标题:
/**
* Automatically set the title as caption, when uploading an attachment.
*
* @see https://wordpress.stackexchange.com/a/188708/26350
*/
add_filter( \'wp_insert_attachment_data\', function( $data, $postarr )
{
// Let\'s target only the uploading process and not the updating of attachments:
if( empty( $data[\'post_excerpt\'] ) && isset( $postarr[\'ID\'] ) && 0 == $postarr[\'ID\'] )
$data[\'post_excerpt\'] = $data[\'post_title\'];
return $data;
}, 10, 2 );