How to hide a page in wordpress made for menu

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 !

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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.

Method 2

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.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x