Skip to content

Commit

Permalink
chore: remove unneeded get_post(s) calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Levdbas committed May 20, 2024
1 parent b83b1f7 commit f645fb0
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 13 deletions.
1 change: 0 additions & 1 deletion author.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

$context = Timber::context([
'title' => $title,
'posts' => Timber::get_posts(),
'author' => $author,
]);

Expand Down
2 changes: 0 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@

use Timber\Timber;

$posts = Timber::get_posts();
$templates = array('index.twig');

if (is_home()) {
array_unshift($templates, 'front-page.twig', 'home.twig');
}

$context = Timber::context([
'posts' => $posts,
'foo' => 'bar',
]);

Expand Down
11 changes: 3 additions & 8 deletions page.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@

use Timber\Timber;

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

$context = Timber::context(
[
'post' => $post,
]
);

Timber::render(array('page-' . $timber_post->post_name . '.twig', 'page.twig'), $context);
Timber::render(array('page-' . $post->post_name . '.twig', 'page.twig'), $context);
1 change: 0 additions & 1 deletion search.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

$context = Timber::context([
'title' => 'Search results for ' . get_search_query(),
'posts' => Timber::get_posts(),
]);

Timber::render($templates, $context);
2 changes: 1 addition & 1 deletion src/StarterSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function add_to_twig($twig)
*/
// $twig->addExtension( new Twig\Extension\StringLoaderExtension() );

$twig->addFilter(new Twig\TwigFilter('myfoo', [$this, 'myfoo']));
$twig->addFilter(new \Twig\TwigFilter('myfoo', [$this, 'myfoo']));

return $twig;
}
Expand Down

0 comments on commit f645fb0

Please sign in to comment.