Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
  • I have an existing asp based blog where all posts contain a post id in their URL (template_permalink.asp?id=123).
  • I have a blank WordPress blog. I will have to recreate all of my posts manually, because the feed from my existing blog doesn't contain the original images (it just has a CDATA block) so I can't import them.
  • I need to to redirect the original posts to their equivalent WordPress post.

I have tried:

  • To 301 redirect all template_permalink.asp?id=xxx URLs to a post id using htaccess but it retains the original id so to make this work I would have to manually change the WordPress post id—which I can't work out to do—so it doesn't hit the right page. My code:

    Redirect 301 /template_permalink.asp http://www.example.com/
    

What I would ideally like is to be able to either:

  • Change the WordPress post id manually to match the original id. Is there a way to do this?
  • Or even better would be to manually add the 200 posts in htaccess and redirect to a pretty URL, in which case please could you advise of how to format this for htaccess?
share|improve this question
    
Can you please paste here your post's sample feed format so we can see if possible to write import script. –  Manish Nov 28 '13 at 17:56
    
Thanks for asking, I have now taken the advice below and can successfully import my blog posts by exporting to CSV from my DB and then importing that file. That just leaves me with the redirect issue. –  Lloyd S Nov 29 '13 at 9:39

2 Answers 2

When you are importing via code (which is practical necessity for large imports) you can supply import_id argument to wp_insert_post() to be used.

There is however no clean/safe way (that I can think of) to specify or modify post IDs manually.

In your case (if you are really stuck with manually created posts) I would add IDs as post meta through editor and when site is hit via old format link extract the ID and look up via meta query if there is matching post to redirect to.

share|improve this answer
    
Thanks, I have now imported my old posts via file, could you expand a little on how I would handle the redirect via the meta query? –  Lloyd S Nov 29 '13 at 9:40
up vote 1 down vote accepted

I have now found a plugin called Redirection that achieves the page by page redirect.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.