Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

frha on "Showing private pages in default page-menu"

$
0
0

I was struggeling to be able to show private pages in the default page-menu when user was logged in.

Finally i was able to do this in a child-theme, but it should have been a standard way to do this regardless of the theme chosen...

I would suggest that the core-developer just adds a few lines in includes\post.php like this :

// Make sure we have a valid post status.
	if ( ! is_array( $post_status ) ) {
		$post_status = explode( ',', $post_status );
	}
  //Added to show private pages if user can view them
  if(current_user_can('read_private_pages')) {
    $post_status[] = 'private';
  }

But since it's a bad idea to change those in my own installation, I can add this through the filter-mechanism like this (in my child-theme's functions.php) :

function my_page_menu_args( $args ) {

  if(current_user_can('read_private_pages')) {
    $args['post_status'] = 'publish,private';
  }
	return $args;
}
add_filter( 'wp_page_menu_args', 'my_page_menu_args' );
}

Viewing all articles
Browse latest Browse all 8245

Trending Articles