I don’t know how to make a plugin so I can’t do what’s suggested here How can I make it so the Add New Post page has Visibility set to Private by default?
so what’s alternative ?
I don’t know how to make a plugin so I can’t do what’s suggested here How can I make it so the Add New Post page has Visibility set to Private by default?
so what’s alternative ?
You must be logged in to post a comment.
Accepted solution is not the correct answer to change the visibility of any post type to any status. Below code is the right way to change the post status.
Updated:
The above filter will change the post status to Private when user will hit Save Draft or Publish button. So on edit page load if you see Status Public then don’t worry.
There is one more filter available to change the status before saving into database. The filter is
status_save_pre
but I didn’t find any documentation on this page so I wrote below code to test it.The above filter saves the post as Private post type as soon as edit page load so one may want to use this filter over
status_edit_pre
but if I usestatus_save_pre
filter I run into an issue, I can’t delete any post. So I prefer ‘status_edit_pre’ over ‘status_save_pre’ until WordPress team fix this bug.Found this on WordPress forums:
You can just add this to functions.php. I’ve tested once and seemed to work fine.
The alternative would be to find someone else to make a plugin.
If you’re using WordPress.com (meaning you can’t install arbitrary plugins on your site), then you’re out of luck. But for a self-hosted WordPress installation, you’ll need to write a plugin and install it on your site. There are no alternatives when it comes to adding custom functionality.
The accepted answer doesn’t work for me. Here’s a simple solution. It will only run the first time you publish any post.