Had to switch the filter to the template_include hook. Don’t know if that is the correct way to do it, but it works:
function _plc_template_include ($template) {
$pages = _plc_get_custom_pages();
foreach ($pages as $slug => $title) {
if (is_page ($slug) && is_file (PLC_TEMPLATES . $slug . '.tpl.php')) {
ob_start();
include PLC_TEMPLATES . $slug . '.tpl.php';
$content = ob_get_clean();
include PLC_TEMPLATES . 'content.tpl.php';
return;
}
}
include $template;
}
add_filter ('template_include', '_plc_template_include', 99999);
I placed the content of the template into a variable and placed all the content into one template to avoid rewriting the header and footer each time, but easily could have just put:
include PLC_TEMPLATES . $slug . '.tpl.php';
return;
instead of the ob_start & ob_get_clean methods.