[resolved] wp_insert_post fron a page (3 posts)

  1. Steffen Jørgensen
    Posted 5 years ago #

    I'm trying to write a form for visitors to submit content (posts) directly from a page I have created.

    I'm using the "wp_insert_post" function, and found this tutorial:

    However, I can't make it post to the database — it just returns a "page not found" when submitted.

    Any pointers or tips?

    Thanks in advance.

  2. ojobson
    Posted 5 years ago #

    At the top of the form, action is left blank:

    Action specifies where the form should send the data. The php, which handles the data from the form must be saved to a file on your web server, at the root of the wp installation. If you were to name this 'frontpost.php', you would amend action as follows:


    That way the form sends the data to the php file, which then processes it.

    Hope that helps - I'm trying to use this too, but i'm getting the following error:

    Fatal error: Call to undefined function wp_insert_post() in /homepages/25/d288611421/htdocs/intranet/front-post.php on line 26

    Something in the php doesn't seem to be working.

  3. John
    Posted 5 years ago #

    If action is left blank and you only have _POST info for the title and content then it works, but if you have any fields that are meant to add meta data, then the php breaks and returns a 404 error.

Topic Closed

This topic has been closed to new replies.

About this Topic