redirect parent pages to child
-
I’d like to apply the following code to categories:
<?php /* Template Name: Go to first child */ $pagekids = get_pages("child_of=".$post->ID."&sort_column=menu_order"); if ($pagekids) { $firstchild = $pagekids[0]; wp_redirect(get_permalink($firstchild->ID)); } else { // Do whatever templating you want as a fall-back. } ?>
If it worked for categories, then I’d be able to show the firse child category content when its parent is called for example via permalink.
For example:
https://www.mydomain.com/parent/ would go to https://www.mydomain.com/parent/childI need this because my parent categories are empty and if you go to https://www.mydomain.com/parent/ you see no contents, only fotter/sidebar/header
thanks!
- The topic ‘redirect parent pages to child’ is closed to new replies.