I want to redirect users on first child page.
for example there is parent page: Page A it has 2 child pages: child1 and child 2
when user click on Page A that redirects user to child 1 page
there are too many redirection plugins to redirect parent to child 1 that is manully set. I want this dynamically
is it possible to redirect the parent page on first child page programmatically?
In cases like this I just add a link to the menu, and change the url to "parent/child"
The following worked like a charm. (http://www.wprecipes.com/wordpress-page-template-to-redirect-to-first-child-page)
To achieve this recipe, you have to create a page template. Create a new file and paste the following code in it:
Save the file under the name redirect.php and upload it to the wp-content/themes/your-theme directory of your WordPress install. Once done, you can use the page template.
Try below code for the same :
Let me know if you have any queries!
Thanks.