Make a PHP script to to make a post draft publish like wordpress

I don’t know the appropriate words to describe my question.

But I want to know if there is some tutorial about how wordpress save publish update there posts.

Read More

As I am working on a project and I am doing my best to accomplish this but I am unable to get 100% result.

For example I successfully save any post and publish for one time then there are many problems when I try to update a published post.

I also facilitate users to preview there post with current changes.

How can I do all these tasks perfectly.

In-short is wordpress’s post method the right thing that I want.

Related posts

Leave a Reply

1 comment

  1. Need more information to understand what problem you are facing. Still i will try to answer your question.

    When we are using wordpress, it save it’s content (post, page or whatever other content you add/change) in a mysql server using php. If you are using php and mysql (==mysqli), then you can do same as wordpres.

    When you first create a post on wordpress, it save one copy on mysql database. when you open that post to edit again, it create another copy of same post includes new edit/changes you mad. the new copy become the valid copy and wordpress save old copy as previous version, it call revision. you call read details here:
    https://codex.wordpress.org/Revisions

    How does view functionality work? “I also facilitate users to preview there post with current changes.”
    when you edit a file, but haven’t save content yet, wordpress will save content as a special revision (check the wordpress revision link). view link will have id of that special revision and you can see that update unsaved content with that link.

    How does autosave work?
    Using ajax/jquery $.post – https://api.jquery.com/jquery.post/
    When you editing the post, wordpress save content using ajax/jquery $.post method which doesn’t require refresh of the page, so you can still be on the page and continue your editing without interepting.

    Please let me know if i miss something.
    Sorry for my broken english, not native english speaker.