Well an easy solution is CSS
<!-- HIDES MENU ITEM IF THE USER IS NOT LOGGED IN -->
<?php if (is_user_logged_in()){
echo "";}
else {
echo "<style type="text/css">
.menu-item-58 {display:none;}
</style>";
};
?>
But if you are trying to code it down see the source of this plugin http://wordpress.org/extend/plugins/if-menu/ — it will help you alot.
While if you just want a coding answer – a simple one – replace the header
<ul>
<?php wp_list_pages(); ?>
</ul>
With the conditional statement
if user not logged in
show
<ul>
<?php wp_list_pages('exclude=17,38' ); ?>
</ul>
where exlude are the pages id you don’t want a not logged in user to see.
while using else commend to show all menu to logged in user
else
<ul>
<?php wp_list_pages(); ?>
</ul>
Hope this helps you. keep us up to date.
Related Posts:
- Change the_title() of a page dynamically
- Create a Page via plugin
- How to create archive page to add in menu
- add_menu_page() with different name for first submenu item
- How to add sub-menu to a menu generated by wp_nav_menu by using plugin
- How do I programatically insert a new menu item?
- Can someone explain what wp_session_tokens are, and what are they used for?
- Add Dividers or Separators Between Nav Menu Items
- Init action hook running late after PayPal’s return url?
- Nav Menu meta failing to import
- How to check WordPress website username and password is correct
- How to edit the properties of a page programmatically?
- Log in from one wordpress website to another wordpress website
- Problems after wp_set_password() containing an apostrophe
- Overwriting Core WordPress Functions with Plugins
- Determine which theme location a wp_get_nav_menu_items is for
- Pages 404 in wordpress
- Can I add pages to my custom menu via script?
- Replacing WordPress menu functionality with a plugin
- How to create a dynamic page based on form data with a plugin?
- Is it possible for a plugin to register a page template file?
- Is it possible to show a different WP menu when using password protected pages?
- Hook event for upload image in the menu
- Calling a function from functions.php in custom page/ blog post
- Why isn’t the Settings API designed to work for plugins using custom admin menus? [duplicate]
- Set a specific page as 404 – not found via my own plugin
- Making WordPress’ page and menus visible only for logged in users, checking session variables
- Delete a specific item menu when I deactivate my plugin
- Add Submenu Link in add_submenu_page That Opens in a New Window
- How to assign a WP 3.0 custom nav menu to a theme’s navigation menu location via script?
- PHP 7 – Class Method Compatibility Issue
- How to add pages to custom menus on the fly [duplicate]
- How do I add a custom sublevel menu specified in one directory to a custom top level menu specified in another directory?
- Add notification bubble notice in navigation using transients
- Is there any way to check for user login and send him to login?
- Proper way to pass credentials in a custom login form to avoid “headers already sent”
- External Authentication, session_tokens not destroyed on logout
- Adding custom fields to WordPress nav menus
- Sub Menu content is being duplicated
- How to customize login process
- Secure Pages Best Practice
- Does wp_login only trigger before an user signs in into the admin panel?
- Logout users upon login, based on caps/role?
- Remove unwanted elements for a wp_nav_menu
- Is this best practice for Dynamically adding items to WordPress menus?
- Password field is empty when using wp_signon();
- How to remove or add submenu item on plugin activate or deactive
- Plugin Development for registered users
- Custom code for WordPress dynamic menu
- How do I access the menus produced by Dashboard > Appearance > Menus
- Enqueue script globally
- wordpress add_submenu_page adds broken link
- WP Enqueue style on all plug-in pages
- ECHO Executing 4 Times In Head
- Menu page with minimum capability as ‘Subscriber’ doesn’t allow ‘Admin’ to access it?
- How do I validate extra pin field on my WordPress login form page?
- Issue with plugin sub menu and pages
- How to redirect home page to another page after login for all user?
- How to add Plugin functionality in WordPress Frontend Menus
- How to list all images used on a specific page?
- Create fixed static pages
- How to hide page links from theme menu
- WP_NAV_MENU filter targets all menus
- How do I add a menu item to a Pods admin menu?
- How to share user data across multiple WordPress websites?
- Set page to draft on plugin deactivation
- Load specific page when a custom URL is hit
- Allowing duplicating users with same user_login and user_email
- How to Login a User inside a Plugin and Redirect to page?
- Using custom IDP with WP
- Plugin frontend page design irrespective of the theme used
- Hiding the WordPress login and password fields from login page
- Custom non-template page on front end fails to render
- remove different admin menu for specific users
- redirect_to how to make it simply work with get parameter or similar?
- Using WP page password protection as defacto login
- How to get an array out of a nav menu if it’s a plugin?
- How do I control the list of Pages an author can see?
- How to add conent (text) to Add New pages form of admin in WordPress
- auto create only 1 wp page in activate custom plugin
- What happens when you create/edit a menu
- Multiple Users Logged In Causing Incorrect Account Returned
- Adding parent custom post type menu option
- Redirect url in plugin to somewhere else?
- Create and style menu
- Change the class of wordpress menu
- Get user logged in status from within a plugin. $current_user not defined
- Need edit profile link in the menu for logged in users
- Create a Custom Login System in WordPress [closed]
- how can I insert a link on login page
- How do I use (or mimic) document.getElementById() on a page loaded from WordPress database?
- Invalid Menu Items
- user can login from single account detail from multiple locations(computer) at the same time [closed]
- Declaration of mandoe_menu_walker::start_el(&$output, $item, $depth, $args) must be compatible with Walker::start_el(…)
- Using a Page Template Not in Theme
- Custom Nav Walker $item->url producing malformed hyperlinks
- Displaying an Uploaded Image as a Custom Avatar in WordPress
- Adding a navigation with wp_nav_menu() to a custom block in the site editor
- Generating Multiple Divi Pages from Database
- Problem with Owl Carousel, infinite loop [closed]