Effect of changing the WordPress site URL

I haven’t yet looked at why there was a problem publishing posts after the WordPress site URL changed. My guess about what’s happening with the posts that you are not able to republish to Discourse is that WordPress thinks the post already exists on Discourse and is trying to update a post instead of to create a new Discourse topic.

You could check that by running this MYSQL query on your WordPress database. Substitute the WordPress post_id of a post you are not able to republish for $post_id.

SELECT * FROM wp_postmeta WHERE post_id = $post_id;

If you are seeing meta_key values for ‘discourse_post_id’, ‘discourse_topic_id’, and ‘discourse_permalink’, that will be the problem. If that is the case, running the following query should allow you to republish the post. Substitute the WordPress post_id for $post_id.

DELETE FROM wp_postmeta WHERE post_id = $post_id AND meta_key IN ('discourse_post_id', 'discourse_topic_id', 'discourse_permalink');

If you like, try this on one post that you can’t republish and that you are sure doesn’t exist on your Discourse forum.

I’m going to make a change to the wp-discourse plugin so that it automatically unlinks posts from Discourse if a 404 (not-found) response is returned from Discourse.