将 Timber 与事件日历插件中更新的日历设计结合使用

Using Timber with the updated Calendar designs in The Events Calendar Plugin

我正在使用基于 Timber 主题的 Wordpress 事件日历插件。我目前正在使用以前记录的方法进行集成,该方法位于此处:

https://theeventscalendar.com/support/forums/topic/events-pages-not-showing-up-in-timber-based-theme/

从插件的 v5 开始,有一个选项[也设置为默认值],它使用更新的日历和事件设计,打破了我当前的集成方法。我尝试更新我的模板 PHP 文件,但收效甚微。

使用 Timber 中的 function() 方法调用相对简单的遗留函数是:

<?php tribe_events_before_html(); ?>
<?php tribe_get_view(); ?>
<?php tribe_events_after_html(); ?>

https://timber.github.io/docs/guides/functions/

然而,在添加到 v5 事件日历的 v2 模板中,他们调用了 class,例如:

use Tribe\Events\Views\V2\Template_Bootstrap;

get_header();
echo tribe( Template_Bootstrap::class )->get_view_html();
get_footer();

我遇到的主要问题是我不确定如何将此 class 暴露给 Timber 上下文。如果有人可以指导我,将不胜感激。我现在使用的功能正常,但 tribe_get_view 功能已被弃用并被视为遗留功能,因此不会永远存在,因此我需要想出某种解决方案。

谢谢!

是的,所以我发布的方法根本不再需要,也不是变通方法。只需确保您有可用的 page-plugin.twig 模板即可。希望这会帮助其他陷入困境的人......

澄清一下,timber/starter-theme 中有一个解决方法,它涉及多个文件,包括一个 'page-plugin.twig' 模板。不要只是添加一个 'page-plugin.twig' 模板并指望修复它。

Third party plugins that hijack the theme will call wp_head() to get the header template. We use this to start our output buffer and render into the view/page-plugin.twig template in footer.php

转到这里https://github.com/timber/starter-theme

将 header.php、footer.php 和 page-plugin.twig 复制到您的主题中,并为您自己的站点进行自定义。