
Are you using private pages? If yes, you probably know that they’re not displayed in the navigation menu. Happilly, here’s a small recipe to change this and show private pages to specific users.

Are you using private pages? If yes, you probably know that they’re not displayed in the navigation menu. Happilly, here’s a small recipe to change this and show private pages to specific users.
To achieve this recipe, simply open the file where your navigation is (You can look up for the wp_list_pages() function) and insert this snippets instead of the function:
<ul>
<?php
wp_list_pages('depth=1&title_li=0&sort_column=menu_order');
if(current_user_can('read_private_pages')) :
?>
<li><a href="<?php echo get_permalink(10); ?>">For Authors only</a></li>
<?php endif; ?>
</ul>
That's all. Your navigation menu now display private pages to specific users.
Thanks to WpEngineer for this awesome recipe!
4 Responses
May be worth adding the last line of the original article:
The 10 at get_permalink(10) is my ID for the page and has to be changed to your scenario
If they’re private why will they be there?
Anyway – are they seen only by admin?
i had this problem and solved it with using a combination of plugins: role-manager and wp-sentry… thanks for this one!
@Plurkr: I have 4 different User-Classes and every class needs their own content showing up, when they login through a front-end ajax-login.
Trackbacks: