Skip to content

Instantly share code, notes, and snippets.

@mozmorris
Last active December 16, 2015 10:48
Show Gist options
  • Save mozmorris/5422319 to your computer and use it in GitHub Desktop.
Save mozmorris/5422319 to your computer and use it in GitHub Desktop.
Redirect to first child WordPress template
<?php
/*
Template Name: Redirect to First Child
*/
$children = get_pages( "child_of=" . $post->ID . "&sort_column=menu_order" );
if ($children) {
wp_redirect( get_permalink( $children[0]->ID ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment