WordPress.org

Forums

Can't publish a post outside of wordpress (3 posts)

  1. SavingAdvice.com
    Member
    Posted 3 years ago #

    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?

  2. Jackson
    Member
    Posted 3 years ago #

    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.

  3. SavingAdvice.com
    Member
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.