admin管理员组

文章数量:1291105

I'm trying to completely disable access to my parents page menu. For example, I have a menu made like this : parent page -> child page 1 -> child page 2

I made a real page for 'parent page' because my backend is better organized. But I don't want that my customers go to www.mysite/parent-page

I tried to put that page in "private" but then on my breadcrumbs child page 1 I have : "home > parent page(private) > child page 1

I don't want it to display the private I just want my parent page in 404 if someone tries to go in.

I hope I was clear. Thank's !

I'm trying to completely disable access to my parents page menu. For example, I have a menu made like this : parent page -> child page 1 -> child page 2

I made a real page for 'parent page' because my backend is better organized. But I don't want that my customers go to www.mysite/parent-page

I tried to put that page in "private" but then on my breadcrumbs child page 1 I have : "home > parent page(private) > child page 1

I don't want it to display the private I just want my parent page in 404 if someone tries to go in.

I hope I was clear. Thank's !

Share Improve this question asked Jun 16, 2021 at 13:26 popcornpopcorn 32 bronze badges 1
  • WordPress doesn't have breadcrumbs functionality out of the box, how are you displaying breadcrumbs? – Tom J Nowell Commented Jun 16, 2021 at 14:00
Add a comment  | 

2 Answers 2

Reset to default 0

Just create a custom template template-redirect-home.php and assign it to that page and redirect to homepage on load with sth like this:

add_action( 'template_redirect', function(){
  if(is_page_template('template-redirect-home.php')){
    wp_safe_redirect( get_home_url(), 301, '');
  }
});

You can also use Custom links in the menu to not access the page directly from the menu.

As you said "I tried to put that page in 'private' but then on my breadcrumbs child page 1 I have : home > parent page(private) > child page 1". So, all you need to do is - Customize your breadcrumb function to hide/remove your parent page from there. WordPress doesn't have default functionality to show breadcrumb. The breadcrumb must be coming from your theme or plugin. So, you just need to find the function for the breadcrumb and edit/customize it.

If you show me your breadcrumb function, I can help you customize that as required.

本文标签: privateHow to hide a page in wordpress made for menu