[title_section title="" icon=""]
Attributes:
{% if posts %} | |
<ul> | |
{% for post in posts %} | |
<li>{{ post.title }}</li> | |
{% endfor %} | |
</ul> | |
{% endif %} |
<?php if ( have_posts() ) :?> | |
<ul> | |
<?php while ( have_posts() ) : the_post(); ?> | |
<li><?php the_title() ?></li> | |
<?php endwhile; ?> | |
</ul> | |
<?php endif; ?> |
<?php | |
/** | |
* Get context. | |
**/ | |
$context = Timber::get_context(); | |
/** | |
* Retrieve current language. | |
**/ |
<?php | |
include('common.php'); | |
/** | |
* Create a list of templates Timber will look for to render. | |
*/ | |
$templates = ['notfound']; | |
/** |
<?php | |
/** | |
* Serve 404 header whenever rendering the notound.twig template. | |
**/ | |
add_filter('timber_render_file', function($template) { | |
if (strpos($template, 'notfound.twig')) { | |
status_header(404); | |
} | |
return $template; |
<?php | |
namespace Example/Model; | |
class MyPost extends \Timber\Post { | |
public function full_name() { | |
// first_name and last_name could be ACF fields. | |
return "{$this->first_name} {$this->last_name}"; | |
} |
<?php | |
add_filter('Timber\PostClassMap', function(){ | |
return [ | |
'post' => '\Example\Model\MyPost' | |
]; | |
}); |
<h1>{{ post.title }}</h1> | |
<p>Written by {{ post.full_name }}</p> |
<html lang="{{ lang }}"> | |
<head> | |
{{ wp_head }} | |
</head> | |
<body> | |
{% block content %}{% endblock %} | |
{{ wp_footer }} | |
</body> | |
</html> |