Livejournal importing

Yeah I finally wanted to get back into long form blogging and decided to give wordpress a go, but I wasn’t sure I wanted to leave behind all my old LJ posts and didn’t really trust LJ not to explode at any given moment – so importing :)  It is a thing that can be done into a wordpress, although the process is a little fiddly.  There’s more below the cut, but if you want access to LJ style “friend locked” posts poke me and I’ll set it up for you, you can authenticate via Facebook, Google, Twitter, etc.

So importing an LJ into wordpress, the process looks something like this:

  1. Sign up for
  2. Create a blog, use the Tools -> Import thing to import from Livejournal by feeding it your username/password.  This will give you the option to make anything non-public set private with a password.
  3. Export the blog from Tools -> Export
  4. Go to your other wordpress and import the into that
  5. That’s all your posts, but hey lets say I want to put them all into a category which I’ve locked up using a combination of press-permit-core and oa-social-login … well here’s where things get fruity :)

Okay so how do we put all the imported private posts into our friend locked category?  Well I’m glad you asked.

    1. Open up your SQL goodies and try the following tricks, first get the name, description and importantly ID of your friends locked category, make a note of that somewhere (if you’re locking with a tag look for taxonomy = ‘post_tag’ instead):
  1. select distinct(t.term_id),tt.taxonomy,,tt.description from wp_terms as t join wp_term_taxonomy as tt on t.term_id = tt.term_id where tt.taxonomy = 'category' ;
  2. Now insert that category into the list for every post that was imported from LJ and has a password set for it, replace “N” with whatever number you got above:
    INSERT INTO wp_term_relationships (object_id, term_taxonomy_id) SELECT pm.post_id,"N" FROM wp_postmeta as pm JOIN wp_posts as p ON pm.post_id = WHERE pm.meta_key = 'lj_itemid' AND p.post_password != '';
  3. Now strip out the password protection from those posts, relying on your locking category to do the work for you:
  1. update wp_posts set post_password = '' WHERE post_password != '' ;

All nice and neat, now go back to and either nuke your whole blog or at least set it private with Settings -> Reading -> Site Visability “I would like my site to be private, visible only to users I choose”

Edit: I’ve since stopped using press-permit-core because the load time is horrific, instead I’m using Groups so here’s how I hopped from one to the other:

  1. Find your term taxonomy for locked posts (it’s “2” for me), with the following:
    select * from wp_term_taxonomy ;
  2. Find all the ID’s of the posts that have that taxonomy:
    select object_id from wp_term_relationships where wp_term_relationships.term_taxonomy_id = 2;
  3. Play with groups… make a locked post, check the ID of it (“520” here), fish in wp_postmeta for it:
    select * from wp_postmeta where wp_postmeta.post_id = 520 ;
  4. Add a meta_key = “groups-groups_read_post”, meta_value = “groups_read_post” set for every ID in Step 2
    INSERT INTO wp_postmeta (post_id, meta_key, meta_value) SELECT object_id,"groups-groups_read_post","groups_read_post" FROM wp_term_relationships where term_taxonomy_id = 2;



Leave a Reply