• I have been creating wordpress pages/posts from outside of wordpress. In other words i’m just running a query to insert a row into wp_posts (with all the same fields filled in as wp-admin does for me). I also create a few post_meta rows (again same as wp-admin does). If I go into wordpress admin afterwords and try to edit the post, no problems. Looks fine and I can edit it just fine. Problem comes when I hit preview. I get a this article not found error (have_posts returns false). If I hit ‘Update’ on the page or post inside wordpress admin, all is good, the preview then works fine. Is there some caching going on I don’t know about? WP_CACHE is not defined in wp-config.php and I don’t have any plugins running. What am I doing wrong?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Why don’t you use native WP functions, ie: wp_insert_post ?

    I wonder if your issue stems from the manually inserted post not having a category. Then when you save it in the admin, it gets assigned the default ‘Uncategorized’ category.

    If nothing else, you could study the source of wp_insert_post to try and locate where you’ve gone wrong.

    Thread Starter 1s0s.com

    (@nsanden)

    I can’t use the native WP functions because my script is completely outside of wordpress.

    I don’t think its an issue with categories either. Posts don’t need a category to be previewed/published normally.

    All I can guess is some kind of native caching mechanism is in place for wordpress posts. I will look more into wp_insert_post like you suggested and post back if I find the solution.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Can't publish a post outside of wordpress’ is closed to new replies.