<?php

use Timber\Timber;

$context         = Timber::context();
$timberPost      = Timber::get_post();
$context['post'] = $timberPost;

if (!$timberPost) {
    Timber::render('pages/404.twig', $context);
    return;
}

if (post_password_required($timberPost?->ID)) {
    Timber::render('pages/single-password.twig', $context);
    return;
}

Timber::render([
    'pages/single-' . $timberPost?->ID . '.twig',
    'pages/single-' . $timberPost?->post_type . '.twig',
    'pages/single-' . $timberPost?->slug . '.twig',
    'pages/single.twig',
], $context);
