I have created a front-end posting and dashboard system for my users to add and edit their own posts. In the dashboard area, I have a list of their posts and the following options for each post: View | Edit | Publish/Un-Publish | Delete
I have all of these links working except for the “un-publish” part. I can get a post to publish if it’s currently in draft, but once it publishes I can’t figure out how to “unpublish” it from the front end, which is a function I’d like my users to have.
For reference, I am using code from this thread to do the Publish part:
Front-End Post Submission
I’ve tried adapting it, but have not succeeded.
I also need similar functionality on the New Post form where I’d like to display a “Save Post” button along side the “Publish” button so a user can save the post a draft so as to not risk losing their work while creating the post.
Thanks for reading, and hopefully someone can help!
You can use
wp_update_post()
to change the status of a post.Use
wp_insert_post()
withpost_status => 'draft'
to save a post.