Wiki Branch Visibility and Protection?


I have a Wiki that needs to be password protected.
That's not a problem I can see how to do that.

However when I add a branch using the "Add New" option the new Wiki doesn't inherit the protection.

I'm attempting to use Front End editing for users to keep things simple for them.

Is there anyway of forcing new branches to inherit protection/visibility?


  • Jonathan

    Hiya @Hagbard Celine,

    Try this snippet of code. You'll want to add it to your theme's functions.php file.

    function password_protect_children_page_contents( $org_content ){
    	if ( get_post_type() == 'incsub_wiki' ){
    		global $post;
    		// Grab ancestors
    		$ancestors = get_post_ancestors();
    		// Loop through ancestors, grab first one that is password protected
    		foreach ( $ancestors as $ancestor ) {
    			if ( post_password_required( $ancestor ) ) {
    				$real_post = $post;
    				$post = get_post( $ancestor );
    				echo get_the_password_form();
    				$post = $real_post;
    	return $org_content;
    add_filter( 'the_content', 'password_protect_children_page_contents' );

    Let us know if this works for you. :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.