Use Parent Pages for URL Structure without Landing Page
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!
Topic wp-redirect url-rewriting urls Wordpress
Category Web