Site icon CodeRevolution Knowledge Base

How to: Add privates pages in navigation menus – CodeRevolution

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!

Exit mobile version