WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ?

share|improve this question
up vote 5 down vote accepted

Found this on WordPress forums:

You can just add this to functions.php. I've tested once and seemed to work fine.

function default_post_visibility(){
global $post;

if ( 'publish' == $post->post_status ) {
    $visibility = 'public';
    $visibility_trans = __('Public');
} elseif ( !empty( $post->post_password ) ) {
    $visibility = 'password';
    $visibility_trans = __('Password protected');
} elseif ( $post_type == 'post' && is_sticky( $post->ID ) ) {
    $visibility = 'public';
    $visibility_trans = __('Public, Sticky');
} else {
    $post->post_password = '';
    $visibility = 'private';
    $visibility_trans = __('Private');
} ?>

<script type="text/javascript">
        try {
            $('#post-visibility-display').text('<?php echo $visibility_trans; ?>');
            $('#hidden-post-visibility').val('<?php echo $visibility; ?>');
            $('#visibility-radio-<?php echo $visibility; ?>').attr('checked', true);
        } catch(err){}
    }) (jQuery);
add_action( 'post_submitbox_misc_actions' , 'default_post_visibility' );
share|improve this answer
Thank you very much just come back today and see your usefull answer :) – user310291 Oct 30 '11 at 15:51

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.

share|improve this answer

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.

function set_post_type_status_private( $status, $post_id ) {
    $status = 'private';
    return $status;
add_filter( 'status_edit_pre', 'set_post_type_status_private', 10, 2 );


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.

function save_post_type_status_private( $status ) {
    $status = 'private';
    return $status;
add_filter( 'status_save_pre', 'save_post_type_status_private', 10, 1 );

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 use status_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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.