How to install Wordpress using SQL

I am porting this site on which I have many posts without recognized images. I started doing this on a page on an interface, but forever. I thought using a database insert could go faster.

The messages do not have an image attached to them, so I cannot use plugins that would automatically set the first image as shown.

Have any of you done this before or could point me to resources?

+4
source share
3 answers

I really was able to get it to work after observing the data from the records. I needed to work with the wp_postmeta table using the query:

 INSERT INTO `wp_postmeta` (meta_value, meta_key, post_id) VALUES ('<post_id_of_image>', '_thumbnail_id', <target_post_id>); 

Hope this helps the other guys out there.

+4
source

I found this question interesting, and since I need to embed images in wp using sql directly, I explored something else. First of all, you need to place a message or page to assign an image. I assume that you inserted the message through the wp interface or called wp_insert_post () or directly by inserting sql into the message $ wp->. Then you need the identifier of this message, say "target_post_id".

Now you need to have the image inserted into the database. Once again, you can use any of the previous methods, but to be quick, I load all my previously modified images into and paste them using sql:

 INSERT INTO $wp->post (post_type, guid, status, post_mime_type) VALUES ('attachment', '<images_url>', 'publish', 'image/jpeg') 

The final step is to associate the message with the image, as cr8ivecodesmith replied:

 INSERT INTO $wp->postmeta (meta_value, meta_key, post_id) VALUES ('<post_id_of_image>', '_thumbnail_id', '<target_post_id>'); 

there are some non-empty fields that wp db will fill with default values

+5
source

step # 1 insert an entry in the wp_posts table for your certification

 INSERT INTO wp_posts (post_type, guid, post_status, post_mime_type,post_parent) VALUES ('attachment', '".$filename."', 'inherit', 'image/jpeg',".$parentpostid."); 

$ filname = url of the image you want to use as a thumbnail, for example. http://yourdomain.com/wp-content/uploads/2014/09/thumbnail.jpg

$ parentpostid = post_id of the message you want to add to your thumbnail.

step # 2 create a meta-post on wp_postmeta for your attachment

 INSERT INTO wp_postmeta (meta_value, meta_key, post_id) VALUES ('".$filename."', '_wp_attached_file',".$attachmentid."); 

$ filename = the file name of your file. e.ge. 2014/09 / thumbnail.jpg $ attachmentid = post_id of the attachment message created in step # 1

step # 3 create a message meta-record to identify the attachment post as a thumbnail for the message you are attaching a thumbnail to.

 INSERT INTO wp_postmeta (meta_value, meta_key, post_id) VALUES (".$attachmentid.", '_thumbnail_id',".$parentpostid."); 

$ parentpostid = post_id of the message to which you want to attach your sketch.

$ attachmentid = post_id of the attachment message created in step # 1

+2
source

All Articles