This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'views/base.twig' %} | |
{% block content %} | |
<h1>{{ post.title }}</h1> | |
{{ post.content }} | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html lang="{{ lang }}"> | |
<head> | |
{{ wp_head }} | |
</head> | |
<body> | |
{% block content %}{% endblock %} | |
{{ wp_footer }} | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>{{ post.title }}</h1> | |
<p>Written by {{ post.full_name }}</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('Timber\PostClassMap', function(){ | |
return [ | |
'post' => '\Example\Model\MyPost' | |
]; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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}"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include('common.php'); | |
/** | |
* Create a list of templates Timber will look for to render. | |
*/ | |
$templates = ['notfound']; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get context. | |
**/ | |
$context = Timber::get_context(); | |
/** | |
* Retrieve current language. | |
**/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( have_posts() ) :?> | |
<ul> | |
<?php while ( have_posts() ) : the_post(); ?> | |
<li><?php the_title() ?></li> | |
<?php endwhile; ?> | |
</ul> | |
<?php endif; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if posts %} | |
<ul> | |
{% for post in posts %} | |
<li>{{ post.title }}</li> | |
{% endfor %} | |
</ul> | |
{% endif %} |
NewerOlder