You can try something like this.
This will check if a page has child pages and if it does then it will redirect the first page in array ordered by menu order.
// get child pages
$child_page = get_pages( "child_of=" . $post->ID . "&sort_column=menu_order" );
if ( $child_page ) {
// get id of first child page
$firstchild = $child_page[0];
wp_redirect( get_permalink( $firstchild->ID ) );
}
Related Posts:
- Page access only from a specific page in wordpress website
- Slug of a child page is accessible with and without the parent slug in the URL
- Check if is on child-page of a particular page
- Check IF is a “single product page” and Check the “role” for a Redirect
- A check for if is parent page, if has children, if has grandchildren
- Can I have two child pages of different parents with the same name?
- Create a “Dummy” parent page for a hierarchy in page listing?
- Create pages automatically if they don’t exist
- Allow only new sub-pages to be created
- Editing Complex Pages in Visual Mode
- Is there a default template file for child pages / subpages?
- Get Permalink for the top level parent of child pages
- How to redirect on particular page in wordpress? [closed]
- Some pages are missing from the Parent Page select in the Editor
- Change admin startpage to Pages-page?
- Different fields in My Profile page depending on user role
- How to display list of child pages of parent page in wordpress?
- Only allow new subpages to be created
- Where does the 404 redirection happen?
- What’s the most minimal way in which a page can be hooked into WP?
- Associate Page with User
- How to change redirect after moving a page to trash?
- Can’t change parent page
- Static files or dynamic WP pages for “static content”?
- Password Protected Page Not Displaying Content After Entering Password
- CMS: Making complex pages editable by the end user
- Show child pages when on a child page
- Remove specific page/post from feed
- Redirect “Sorry, you are not allowed to access this page.” to Home
- select a private page as parent for another private page
- How to redirect a page to subdomain?
- Custom page template not working
- Slug is redirecting to 404
- WordPress pages with hierarchy
- load common thank you template with different content for different pages
- remove/hide pages from users backend
- List child pages by slug not ID?
- If a page does not exist, include a different page?
- How to redirect a page to another?
- get_pages() & “child_of”
- Page redirects to archive
- Combining ‘depth’ with ‘include’ in wp_list_pages()
- Unique page URL redirect to file_get_contents() at domain
- Removing Parent Page URL While Keeping the Navigation Intact
- Change base URL of pages created by certain users
- Organizing Your Pages
- Custom page template for multiple pages
- How to detect if is_404() or is_page() or etc…? [closed]
- Can a user find a child page?
- Display child pages in sidebar of parent page in wordpress
- Display child pages in a parent page? [closed]
- How to list a page tree?
- How can I use “getarchives_where” to get monthly archives for static pages?
- List all posts with the parent or grandparent of a page with a specified ID
- Add a static page that links to homepage
- Create page template with some static contents
- Can I change the “Home” text in the menu?
- logout redirect only from admin page
- WordPress page not taking precedence over server directory
- Folder wordpress page redirect
- How to rewrite a page url
- Keep page hierarchy in wp_list_pages, even if on a child or grandchild
- redirect index.html inside folder to wordpress page of same name
- Get rid of “comment” field on non-blog pages [duplicate]
- How do you set the default page in WordPress?
- Listing all child-pages of a parent-page on the parent-page and each child-page?
- How to control display of page lists on sidebar that doesn’t have childrens
- Check if page has subpages
- Exclude child pages args array
- How should I set up a Tumblr blog at a WordPress Page?
- Pages that don’t look like blog posts?
- After creating a new page, filling the page with structure
- Search anything from a Child and Sub-Pages of their Parent page
- How to get an array of pages ID by some page’s slug and all its children pages in get_posts() function?
- URL redirect to home page issue in word press site
- Return true if parent page id matches
- Problem with deleting a “Page”
- WordPress redirects to login page when I enter url.com/index.php
- If page or sub page not working as expected
- How to use wp_dropdown_pages or wp_list_pages to accomplish a menu like this?
- Cannot use old slug – it just 301s to site home page
- Display grandchild page content on parent page
- Display inner pages like posts.[Like how post excerpt works]
- How to show the view more on my display of pages shortcode
- Redirect Every Instance of The Author Template Pages to Custom Author Pages
- Childpage title + content on Parent Page
- Allow arbitrary text after page URL
- How to copy specific page content and create child page?
- Pages redirecting to homepage
- Firing page_publish where page is child page
- How to finish this loop?
- How do I make just one of my pages a Blog Page?
- displaying child pages in columns when on a parent page
- How to make in post Parent page children page list nummbered
- Woocommerce – Making product pages child of shop
- pagination does not work with query_posts. Help! [duplicate]
- How to remove title (home) from static page skeleton template
- Multiple WordPress Pages
- How to create an user defined page?
- Load new Posts on Scroll on Page