• 注册
热门标签
↑ 收起导航

wordpress更改POST类型

有需要将 post_type 由 post 更改为 attachment,也就是将文章类型改为多媒体,相应的数据库表 wp_postmeta 也需要新增几项内容:_wp_attached_file、_wp_attachment_metadata

首先更改类型,进入数据库表 wp_posts,使用如下SQL:

UPDATE `wp_posts` SET `post_status` = 'inherit',
	`post_name` = 'filename',
	`guid` = 'http://yangjunwei.com/wp-content/uploads/2012/09/filename.jpg',
	`post_type` = 'attachment',
	`post_mime_type` = 'image/jpeg' WHERE `wp_posts`.`ID` =950;

接着进入表 wp_postmeta,新增几项内容:

INSERT INTO `wp_postmeta` (`meta_id`, `post_id`, `meta_key`, `meta_value`) VALUES (NULL, '950', '_wp_attached_file', '2012/09/filename.jpg');

INSERT INTO `wp_postmeta` (`meta_id`, `post_id`, `meta_key`, `meta_value`) VALUES (NULL, '950', '_wp_attachment_metadata', 'a:5:{s:5:"width";i:800;s:6:"height";i:600;s:4:"file";s:35:"2012/09/filename.jpg";s:5:"sizes";a:2:{s:9:"thumbnail";a:4:{s:4:"file";s:35:"filename-150x150.jpg";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:10:"image/jpeg";}s:6:"medium";a:4:{s:4:"file";s:35:"filename-300x225.jpg";s:5:"width";i:300;s:6:"height";i:225;s:9:"mime-type";s:10:"image/jpeg";}}s:10:"image_meta";a:10:{s:8:"aperture";d:3.2000000000000002;s:6:"credit";s:0:"";s:6:"camera";s:8:"DSC-HX30";s:7:"caption";s:0:"";s:17:"created_timestamp";i:1368620732;s:9:"copyright";s:0:"";s:12:"focal_length";s:4:"4.45";s:3:"iso";s:3:"100";s:13:"shutter_speed";s:5:"0.001";s:5:"title";s:0:"";}}');

这里有几个点要保持一致:

post_name:filename; post_id:950

版权声明:转载请注明来自杨俊伟博客,本文地址:http://yangjunwei.com/a/976.html
除非注明,杨俊伟博客文章均为原创,转载请注明出处和链接!
 

发表评论 



我还是想用邮箱注册

登录

忘记密码 ?

用第三方帐号快捷登录

已有账户?前往登录吧~

注册