So this is more a philosophical question than anything, and if I'm asking this in the wrong place, I'm happy to remove the post:

What's the best way to use a parent page for structure while keeping that page inaccessible to users? I'm running into two issues:

First, I want to use the parent page in the main menu so that I can take advantage of WordPress's current-menu-parent and like classes for styling purposes. I know that normally you can set a child page as a menu item and simply rename it to match it's parent, but then I lose the classes for styling the "parent" (sibling) menu item when on a sibling page.

Second, this parent page needs to be inaccessible to users, so that even if they modify the URL in their web address bar, they can't access the page and (possibly) are redirected to the first child page.

In the past I've either gone with the child-page-labeled-as-parent-in-menu route and then used jQuery to highlight the proper menu item, or I've used wp_redirect() to keep the user from the parent page. Both seem kind of hack-ish to me and the jQuery method doesn't allow for scaling or reordering pages as well as I'd like.

Does anyone have any suggestions? If using wp_redirect() is okay, should it be a 302 or 301 redirect? 302 seems better to me because then the website pages and be reordered and we won't face any issues with users having the redirection cached.

Anyway, I'm at a loss as to what the best practice is in this situation. Any advice would be appreciated!

  • I had a similar situation recently. I added parent pages for structure sake, and then added a redirect to the first child page in case someone landed on the parent page by accident.
    – gdaniel
    Apr 8, 2015 at 16:44
  • Yeah, it definitely works, I'm just not sure if a redirect is appropriate or not. Maybe this is just the way everyone accomplishes it...?
    – jmp
    Apr 8, 2015 at 19:45
  • The only other way I can think of is rewriting URLs, but it seems to cause way more issues when you try to do that.
    – gdaniel
    Apr 8, 2015 at 20:03

1 Answer 1


It seems that you might be creating a parent page for the wrong reasons. There are other classes that will be added to identify the current menu item and you can also change that behavior using a menu walker.

The current menu item should have current-menu-item class added to it so you could leverage that in your CSS.

Also in the menu setup instead of addding a parent page create a Custom Link with URL set to # if what you're after is just creating the right menu hierarchy.

As for the redirect, you can accomplish the functionality you describe by editing the page template php without the need for a child-parent relationship.

  • Maybe I should have been more clear. I want to parent page for the URL structure, i.e. www.example.com/gallery/photos/ or www.example.com/gallery/videos/. The "Gallery" page is necessary for the structure of the site. And as far as the redirect, I know how to accomplish it, I just don't know if it's the best course of action.
    – jmp
    Apr 8, 2015 at 19:43
  • 1
    In my opinion, you should have content for every "directory" of the URL. So if you have domain.com/gallery/photos/ and domain.com/gallery/videos/, perhaps serve domain.com/gallery/ as an archive of all types of "galleries" available on your site. Dec 31, 2016 at 22:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.