• After truedeath.com was constantly bombarded with spam comments, I decided that enough was enough. I backed up the database and erased everything. After installing everything again and with new spam-tastic measures in place, the cleanliness of the blog was a fresh breath of clean air.

    But 1 month into blogging on a new installation, I realise that I’d like to somehow bring back the old posts somehow.

    I’ve backed up both databases old and new and have phpmyadmin running on my computer to test things out before I try anything on the live server.

    Does anybody know how I can go about doing this? I tried moving the wp_posts table from OLD to the NEW one using phpmyadmin but since there is a clash in the autonumbering of the posts, this is not possible. There is no conflict with the authors as everything is as it was before. I am only interested in porting over the posts.

    Help!

Viewing 6 replies - 1 through 6 (of 6 total)
  • You’d have to:

    1. Export and download the wp_posts table you want to move over to a sql (text) file.

    2. Open the file in a text editor.

    3. At each INSERT line edit out the post ID value (first value after…VALUES –just replace the numeric value with "").

    4. Import the file to your new database install. The ID field will auto-increment from the last post ID used.

    Note that the posts will not have any assigned categor(y|ies), but these can be quickly edited in.

    Thread Starter zaaba

    (@zaaba)

    Thank you! I’ll do that tonight and see what happens…

    Thread Starter zaaba

    (@zaaba)

    I’ve managed to copy all of my old posts AND managed to change the authors to the right people. The problem is now that the old posts have no categories assigned.

    Instead of manually clicking EDIT on the wp-admin screen for each and every one of these entries (OVER 200++!!!), is there a mysql command I can run so that I assign all posts with post_ID > 50 to the default category?

    That would be SOO useful. Thanks!

    Uh, don’t know an easy way to do this with a query line (as in one INSERT places values for all the posts). I can, however, pass along a bit of PHP that could do it:

    http://guff.szub.net/source/fragment-21761.php

    Directions:
    1. Copy contents of the above link to a php file: insert.php.
    2. Edit $start and $end variables to reflect the first and last post IDs for your new entries.
    3. Upload insert.php to your blog’s root directory, i.e. where wp-blogheader.php is located.
    4. Load that file (just once!) in your browser. If all’s well, it should report the number of rows inserted into your database.
    5. If 4 was successful, delete insert.php from your site.

    Thread Starter zaaba

    (@zaaba)

    Sweet! Worked like a charm. What’s best was I knew how to alter the code to fit certain posts that were from another catagory. Thanks alot Kafkaesqui! That really made my day. Whoo hoo!

    Now to sort out the archives PROPER 🙂

    Cheers!

    Thread Starter zaaba

    (@zaaba)

    BTW, the code is as follows just in case the page link above goes dead:

    <?php
    require('./wp-blog-header.php');

    $start = '100';
    $end = '101';

    for ($i=$start; $i<=$end; $i++){
    $result = $wpdb->query("INSERT wp_post2cat VALUES (NULL, $i, 1)");
    if($result == 1) {
    $count++;
    }
    }
    echo "$count rows affected.";
    ?>

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Merging 2 WP installations’ is closed to new replies.