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

Version: 1.0.4
Added/Updated: 2015-08-11
Authors: marcus, dsdsdsds