I need to insert multiple posts using just raw MySQL with the following:
Check if post duplicated by post_name
field or not and IGNORE inserting if so.
I need to insert a custom taxonomy called newspaper
for the post.
Create custom fields with the new post I already registered and I have the keys fifu_image_url
, fifu_image_alt
, and _cmb_link
I'm not SQL expert so I just did the basic query like so:
INSERT INTO `ctapp_posts`(`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`)
VALUES ?
This won't throw errors, and won't insert if duplicate.
INSERT IGNORE INTO wp_posts (post_name)-> VALUES('. $postName. ')
A bit more tricky. But you can read about the relations here: https://codex.wordpress.org/WordPress_Taxonomy
You can log into the database and create new columns in wp_posts. Just set them to default null . This won't disturb the rest.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.