I'd like to add the posts in my loop the ability to toggle them between different post statuses (e.g. publish/draft).
What's the best way to do it?
Thanks in advance!
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.Sign up to join this community
There isn't much native functionality in WP to apply admin powers on front end. Front-end Editor plugin is usually great for such, but changing post status is one feature it seems to lack (maybe it's worth suggesting to scribu).
So you are basically stuck with writing this from scratch - implementing JS on front end to make Ajax request and backend handler for it. Unless you need this functionality constantly and daily I would not bother with spending time on it.
My suggestion is to create a modal popup with an iframe, that loads edit post page "above" the front end page. (use the edit post link and jQuery) Then set the iframe onLoad to hide everything but the publish meta box, where you toggle the draft/ publish. Also set the iframe onunload to reload parent window (the front end behind the modal). When saving to draft/ publish, the main site view reloads with current status for that post.
this is suitable for listed posts, in the category view, to fast remove unwanted stuff.
You can power a lot of admin stuff from the front end with this teq.
The iframe script is tricky and this is an old question, I might paste some code if requested.