ProcessWire
Recipes_

Quick ProcessWire first child redirect snippet

Problem

From time to time it happens on a website project that you don’t really have pages with teaser- or distributing-functions, but are in need for a first child redirect.

Solution

Use ProcessWire API to redirect:

<?php
/**
 * Template: First Child redirect
 *
 */

// if current page has children (published, not hidden), redirect (HTTP 302) to its first child
if($pages->count("parent=$page")) $session->redirect($page->child->url, false);

Resources