Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is one way of doing it. This worked for me:</p> <p>1) just execute 2 separate MySql queries. The first one inserts the post values into the wp_posts table. You should insert into all columns except in the column "guid" insert some placeholder, like "0".</p> <p>2) the second query is executed right after the first one and here you can call the LAST_INSERT_ID() function to get the true last insert ID of the previous query. This second query updates the "guid" field with the right ID number.</p> <p>You can insert this into the loop for mass-inserting of WP posts from csv file for example.</p> <p><strong>You should do this when the site is off-line or lock the tables first so no other query request comes in between form somewhere else.</strong></p> <p>Example: 1st query (sorry for the column formatting but it is easier to debug):</p> <pre><code>mysql_query("INSERT INTO wp_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 ( 'null', '1', '$timestmp', '$timestmp', '$content', '$posttitle', '', 'publish', 'open', 'open', '', '$postname', '', '', '$timestmp', '$timestmp', '', '0', '$uiai', '0', 'post', '', '0' )") or die(mysql_error()); </code></pre> <p>2nd query:</p> <pre><code>$uid = mysql_insert_id(); $uiai = 'http://yoursite.net/wordpress/?post_type=post&amp;#038;p='.$uid; mysql_query("UPDATE wp_posts SET guid = '$uiai' WHERE ID = '$uid'"); </code></pre> <p>...also, when you are looping through many inserts, sometimes it can max out the maximum allowed execution time for PHP script and the upload gets interrupted. It helps to use set_time_limit(0); throughout the script so the max allowed time counter is regularly reset.</p> <p>...hope this helps :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload