WordPress Copy Post Plugin

Have you ever been in a place where you’re maintaining two blogs and want to copy posts from one to the other? I wrote a WordPress plugin that does just that.  In our case it copies from Dayspring’s internal blog to our public one.  This removes the tedium of having to copy content, comments, and tags manually.  It also preserves the original post author and date.

First, a few assumptions and caveats.

  • The author of the post you are copying must have an account on the target blog with the same login name, though the IDs don’t have to be the same.
  • Categories assignments are not copied over, mainly because in our case the categories on the two blogs are different and there isn’t a clear mapping from one to the other.
  • Comments attributed to registered users retain this attribution only if the commenter has an account on the target blog (just like the author).  If the commenter doesn’t have an account, the comment is still copied, but it’s treated as if it were made by an unregistered visitor.

Use the copy post feature to send a post to a target blog.  You’ll need the post ID, which is available by looking at the edit link for the post.  The plugin will copy the post content, tags, and comments.  The original author and post date will be retained.  All category information will not be copied over.  The resulting post will be set as a “private” post so allow you to set the categories and make edits before it goes live.  Also, you’ll need to be an admin on the source blog to use the plugin.

The settings for the target blog are configured directly in the WordPress Admin interface, making it possible to install and configure the plugin without needing to edit any code.

You can find this Copy Post plugin in the WordPress Plugin Directory.

18 Responses to “WordPress Copy Post Plugin”

  1. Blogger 101 Blogger 101 says:

    I am very interested in this plugin as I need to move blog content often. I coudn’t find it on Wp, please let me know where is available.
    Thank you

  2. Jeffrey Wong Jeff W. says:

    Blogger 101: I’ve submitted the plugin to the WordPress plugin directory. You can find it here: http://wordpress.org/extend/plugins/copy-post/

  3. Marko Marko says:

    After activating this on a wp 2.8.4 / php5 installation, I wanted to go to the settings page of the plugin, as per instructions, but I got a 404 error.

    But even if it did work properly, i don’t see why the plugin would need direct access to mysql? You’re already logged on, with all admin-functions available.

    • Jeffrey Wong Jeff W. says:

      Marko: Looks like I had a bit of trouble in packaging the plugin for distribution. I’ve corrected the directory structure which should resolve the 404 error you were getting. Update to version 0.2.0 and give it another try.

      The plugin needs direct access to the destination blog’s MySQL server. This plugin is for copying a post from one instance of WordPress to a separate instance of WordPress. It is not intended to duplicate a post on the same WordPress instance. Yes, the plugin has access to the source blog since you’re logged in, but it needs access to the destination database. The destination database might be on the same server as the source database or it could be on a server located halfway around the world (or even halfway across the galaxy if you could get an internet connection out there).

  4. Alberto Alberto says:

    Hi Jeff!
    Thanks for your great job! It save my life!
    Just one question: is it possible to copy more than one post at time?
    Putting a comma between ID’s ?

    Thank you.

    Alberto

  5. Gabriel Gabriel says:

    Can you help me through the Options… I am definitely not internet saavy but I own everything on the blogs so, please tell me hoe can a have the data needed configure the blog.

    Do I need to install the plugin in both blogs or how does it work, do i install it first in the one with the original post?

    Options
    Remote Blog URL (ex. http://blog.dayspring-tech.com/, including trailing slash)
    Remote Database Host
    Remote Database User
    Remote Database Password
    Remote Database Name

    • Jeffrey Wong Jeff W. says:

      Hi Gabriel,

      The remote blog is the WordPress blog that you are copying a post to, the plugin only needs to be installed on the blog that has the original post. You also need to be able to log into the MySQL server of the new blog.

      Remote Blog URL: The URL of the new blog.
      Remote Database Host: The hostname or IP address of the MySQL server for the new blog. This might be the same as the DB_HOST from the new blog’s wp-config.php file. Unless the original blog and new blog are on the same server, this shouldn’t be “localhost”.
      Remote Database User/Password: Username and password for the MySQL server. You can probably use the same user as you have in the new blog’s wp-config.php file.
      Remote Database Name: Use the database name that is in the new blog’s wp-config.php file.

  6. Daniel Daniel says:

    Nice plugin! Just what I was looking for. I am combining several small blogs into one to be more efficient. Will you add category matching in a future version?

  7. Paul Paul says:

    Hello,

    Great idea for a plugin. I’m currently trying to get it to work and I’m running in to a problem. Whenever I try to copy a post I get an error saying the user doesn’t exist on the other blog but I know that they do.

    Do you have any ideas why I might be getting that?

    Thanks,
    Paul

    • Jeffrey Wong Jeff W. says:

      Hi Paul,

      The plugin looks for a user with the same username, but the user ID’s don’t have to be the same.

      • Paul Paul says:

        Hi Jeff

        Thanks for responding! It turns out that the problem was I have non standard table prefixes, so instead of ‘wp_posts’ I have ’something_posts’. I updated the code in the plugin to use the non standard prefixes and it worked.

        Is there a way to copy the post attachments over as well?

        Thanks!
        Paul

        • tech tech says:

          I keep getting ERROR: Author (name) does not exist on target system!

          I have verfied both usernames are identical but yes the source blog has non standard table prefixes how can i edit the code to reflect this?

          Basically instead of wp_posts it has wpi9_posts etc etc..

          • Jeffrey Wong Jeff W. says:

            Hi,

            The table prefixes of the source blog should be handled by WordPress’ own database functions. However, the target blog table prefixes are expected to be the standard wp_. For now, you’ll have to edit the copy_post.php file to change the target blog table prefixes.

        • Jeffrey Wong Jeff W. says:

          Hi Paul,

          I’m glad you were able to figure out what was going on and solve your problem.

          We didn’t have many attachments, so we opted to manually transfer the few we did have instead of adding the feature to the plugin. I hope the plugin still provides you some value even in its basic form.

          • tech tech says:

            Hello
            Yeah i just checked target blog and its standard prefixes too And i fixed by changing target host as localhost and not domain name…not sure if that what the problem was but it worked.

            Thanks

  8. ibrahim ibrahim says:

    Hi there,
    May i know that how do i find the post id from my source blog to destination blog? like what is the post id and which type of value it is?

    • Chi-Ming Chien Chi-Ming says:

      On your source blog, when you’re in the admin backend, find the post you want to copy and “Edit” it. The URL in your browser’s address bar will then display the Post ID:

      Example/ If your URL says:

      /wp-admin/post.php?action=edit&post=1234

      the post ID is 1234

  9. Enrico Enrico says:

    Hi,

    I keep getting ERROR: Author (name) does not exist on target system!

    I have verfied both usernames are identical and have the same standard table prefixes between the 2 blogs “wp_”.
    Can you help me, please?
    I work with WP 2.91. Thanks
    Best,

Leave a Reply