when navigating through the pages of the site there is no way to go back using the “Back” button in the browser
it only works after pressing it twice
I do not have SSH access on my shared hosting, so I cannot install composer. This means I can’t use Timber 2.0 either. Too bad there is no plugin version of this, now I have to remove all timber/twig code in my theme and replace it with php. I hope that there will still be a plugin version of timber 2.0?
]]>Hello,
I notice since Timber version 1.19, the {% if site.language == ‘pt-PT’ %} stopped working. I have WPML. When I downgrade to 1.18.2, it’s working.
I use this workaround in my staging site:
{% if site.link == 'https://mywebsite.com' %}
but I would prefer a better alternative.
I’m planning to upgrade Timber, but step by step.
Can someone help me?
]]>?Support for Timber 1.x has been dropped and your issue will probably not be addressed. We encourage all Timber users to migrate to Timber 2.x, see the migration guide for an overview of what’s changed and what you might need to do in order to port your theme. If you were using the plugin version we have this guide on Managing Timber with Composer.
For more information, please visit:
]]>All the image/content sliders on the site aren’t working properly. I want them to layout horizontally on PC and laptop (and tablet as far as possible) and it does this if viewed when I am logged in to the admin. For all visitors who are not logged in, the containers stack vertically. (see screenshots)
]]>I have a lot of Depracated messages after upgrading from PHP 7.4 to 8.2
Deprecated: Creation of dynamic property EPSite::$blog_id is deprecated in?/var/www/html/my_site/wp-content/plugins/timber-library/lib/Core.php?on line?71
Deprecated: Creation of dynamic property EPSite::$domain is deprecated in?/var/www/html/my_site/wp-content/plugins/timber-library/lib/Core.php?on line?71
Deprecated: Creation of dynamic property EPSite::$path is deprecated in?/var/www/html/my_site/wp-content/plugins/timber-library/lib/Core.php?on line?71
Deprecated: Creation of dynamic property EPSite::$site_id is deprecated in?/var/www/html/my_site/wp-content/plugins/timber-library/lib/Core.php?on line?71
Deprecated: Creation of dynamic property EPSite::$registered is deprecated in?/var/www/html/my_site/wp-content/plugins/timber-library/lib/Core.php?on line?71
Deprecated: Creation of dynamic property EPSite::$last_updated is deprecated in?/var/www/html/my_site/wp-content/plugins/timber-library/lib/Core.php?on line?71
Deprecated: Creation of dynamic property EPSite::$public is deprecated in?/var/www/html/my_site/wp-content/plugins/timber-library/lib/Core.php?on line?71
Deprecated: Creation of dynamic property EPSite::$archived is deprecated in?/var/www/html/my_site/wp-content/plugins/timber-library/lib/Core.php?on line?71
Deprecated: Creation of dynamic property EPSite::$mature is deprecated in?/var/www/html/my_site/wp-content/plugins/timber-library/lib/Core.php?on line?71
Deprecated: Creation of dynamic property EPSite::$spam is deprecated in?/var/www/html/my_site/wp-content/plugins/timber-library/lib/Core.php?on line?71
Deprecated: Creation of dynamic property EPSite::$deleted is deprecated in?/var/www/html/my_site/wp-content/plugins/timber-library/lib/Core.php?on line?71
Deprecated: Creation of dynamic property EPSite::$lang_id is deprecated in?/var/www/html/my_site/wp-content/plugins/timber-library/lib/Core.php?on line?71
Deprecated: Creation of dynamic property EPSite::$post_count is deprecated in?/var/www/html/my_site/wp-content/plugins/timber-library/lib/Core.php?on line?71
Deprecated: Creation of dynamic property EPSite::$home is deprecated in?/var/www/html/my_site/wp-content/plugins/timber-library/lib/Core.php?on line?71
Do you have a solution please ?
WordPress: 6.2.2
Timber: 1.22.1
I want to display an ACF field in the front end. It’s a text value within a group.
See screenshot:
I added the value in two different ways to the context:
// Add whole post to context
$context = Timber::get_context();
$post = new Post();
$context['post'] = $post;
// Add specific value to context
$post_data = get_field_objects();
if (isset($post_data['banner']['value'])) {
$banner = $post_data['banner']['value'];
$context['banner_text'] = $banner['text'];
}
Then, in twig, I do:
TEXT from post context: {{ post.banner.text }}<br>
TEXT from forced value: {{ banner_text }}
And I get this result:
TEXT from post context:
TEXT from forced value: “the value i wrote for this field”
The provided value via context is not set.
What am I doing wrong? Isn’t this how I am supposed to display ACF fileds with Timber?
]]>After upgrading from PHP 7.4 to 8.0 all works fine.
After upgrading from PHP 8.0 to 8.1 Timber throws several deprecation messages:
Deprecated: Return type of Twig\Node\Node::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/wordpress/wp-content/plugins/timber-library/vendor/twig/twig/src/Node/Node.php on line 213
Deprecated: Return type of Twig\Node\Node::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/wordpress/wp-content/plugins/timber-library/vendor/twig/twig/src/Node/Node.php on line 221
Deprecated: Return type of Twig\Markup::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/wordpress/wp-content/plugins/timber-library/vendor/twig/twig/src/Markup.php on line 38
Hi everyone.
I think i might just have found a bug in timber. Let me explain:
I have a thumbnail size that is 2048x2048px. lets call it xlarge
When I upload an image of 2000x4196px, WP correctly makes a xlarge thumbnail of 1000x2048px
When I now crop this image to landscape format 2000x1000px, wordpress doesn’t generate a xlarge thumbnail since it’s below the 2048px threshold.
I include the image in my twig file with
{{ Image(image).src('xlarge') }}
.. wordpress or timber automatically takes the old, uncropped xlarge thumbnail since for the cropped version, there is no xlarge thumbnail.
is this a bug in timber or in wordpress? Should i open a github issue?
thanks in advance
]]>WPML won’t work with Cached files. How can we remove the caching system?
]]>Hello!
Will using this plugin improve my wordpress security?
I am not very proficient in security issues, as I only design and code themes.
Thank you!
]]>Hi, I am upgrading PHP on this website, since we are using PHP 7.4, however, once I go to PHP 8.0+ I get a Fatal error and I see this on the error log:
PHP Fatal error: Uncaught Error: Undefined constant "ENV" in /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Extension/CoreExtension.php:1661
Stack trace:
#0 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Extension/CoreExtension.php(1661): constant('ENV')
#1 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Environment.php(497) : eval()'d code(30): twig_constant('ENV')
#2 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Template.php(453): __TwigTemplate_53e9d8e1532f224322e40f11d9628ced0ef859351326ec40020691e39bf7212b->doDisplay(Array, Array)
#3 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Template.php(420): Twig\Template->displayWithErrorHandling(Array, Array)
#4 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Environment.php(497) : eval()'d code(84): Twig\Template->display(Array)
#5 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Template.php(453): __TwigTemplate_463bbf3a9ad038b5ee00f4f934eb82c973c950e04f16fdf7b490be87ad3d210b->doDisplay(Array, Array)
#6 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Template.php(420): Twig\Template->displayWithErrorHandling(Array, Array)
#7 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Environment.php(497) : eval()'d code(35): Twig\Template->display(Array, Array)
#8 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Template.php(453): __TwigTemplate_6117eef2967e4024a8ddd13d22f98637553697006029f77f64e8511beda77b5b->doDisplay(Array, Array)
#9 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Template.php(420): Twig\Template->displayWithErrorHandling(Array, Array)
#10 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Environment.php(497) : eval()'d code(31): Twig\Template->display(Array)
#11 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Template.php(453): __TwigTemplate_1412182097d0a23bc5f170f22c3537c40d9efcdedeb01625fc6e0e9929b2a5d5->doDisplay(Array, Array)
#12 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Template.php(420): Twig\Template->displayWithErrorHandling(Array, Array)
#13 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Template.php(432): Twig\Template->display(Array)
#14 /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/TemplateWrapper.php(47): Twig\Template->render(Array, Array)
#15 /dom42117/wp-content/plugins/timber-library/lib/Loader.php(79): Twig\TemplateWrapper->render(Array)
#16 /dom42117/wp-content/plugins/timber-library/lib/Timber.php(334): Timber\Loader->render('page.twig', Array, false, 'default')
#17 /dom42117/wp-content/plugins/timber-library/lib/Timber.php(383): Timber\Timber::compile(Array, Array, false, 'default', true)
#18 /dom42117/wp-content/plugins/timber-library/lib/Timber.php(410): Timber\Timber::fetch(Array, Array, false, 'default')
#19 /dom42117/wp-content/themes/accedian/page.php(70): Timber\Timber::render(Array, Array)
#20 /wordpress-versions/6.1.1/wp-includes/template-loader.php(106): include('/dom42117/wp-co...')
#21 /wordpress-versions/6.1.1/wp-blog-header.php(19): require_once('/wordpress-vers...')
#22 /wordpress-versions/6.1.1/index.php(17): require('/wordpress-vers...')
#23 {main}
thrown in /dom42117/wp-content/plugins/timber-library/vendor/twig/twig/src/Extension/CoreExtension.php on line 1661
I went back to PHP 7.4 and it is ok now, do you guys have any idea?
Timber Plugin is on its latest version.
]]>An issue was reported to me about pages using a specific twig template, so I created a test page and discovered that when using the preview in a new tab feature in the wordpress editor, the page will load expect for the code in the twig template. Upon a second click of the preview button, all of the code in the twig template will load. Has anyone seen this behavior before?
]]>I have an author archive page for a WordPress author that doesn’t have any Posts that shows zero posts. I have an ACF field that allows me to add this WordPress user as a “secondary author” to select blog Posts and I would like to modify the default query for this particular author archive page so that I can get posts that include that author in the ACF secondary authors field.
I’m using \Timber\PostQuery and would like to continue using it because it gives me an easy way to do pagination.
Is this possible and if so, any suggestions on how I would do this? I’ve tried the following so far but nothing works:
global $wp_query;
$wp_query->query = [
'meta_query' => [
'relation' => 'AND',
[
'key' => 'secondary_authors',
'value' => 'SOME_VALUE',
'compare' => 'IN'
]
]
];
$context['posts'] = new Timber\PostQuery($wp_query);
This doesn’t work – the author archive page in question still shows no posts. I’ve tried printing out $wp_query and simply changing the author to a different author to see if I can force all author archive pages to show the posts for that hard coded author and that doesn’t even work. It appears that modifying $wp_query and passing it into the \Timber\PostQuery class constructor when instantiating it doesn’t do anything.
I’ve also tried the posts_pre_query
filter but it doesn’t fire for an author archive page that doesn’t have any posts.
Hi,
I see a problem with version 1.21.0 of Timber.
A fatal “Fatal error: Uncaught LogicException: Unable to register extension “Twig\Extension\DebugExtension” as it is already registered.” is triggered. In fact, this extension can sometimes be added manually in certain themes..
It possible to test if DebugExtension is not already added before adding it in Timber?
I’m trying to create a custom post preview / excerpt when displaying a paginated list of posts (i.e., the standard Loop). I’m doing something like this
$context['posts'] = new PostQuery();
Timber::render('home-page.twig', $context);
and in home-page.twig
{% for post in posts %}
... other html like post title ...
<p>{{ post.preview.length(25) }}</p>
{% endfor %}
{% include 'pagination.twig' with { pagination: posts.pagination({show_all: true}) } %}
I want to be able to use my own class method to create a custom excerpt based on the post content (I want to grab the first paragraph and use that).
How would I do that? It’s not clear if this is doable using the PostPreview class (https://timber.github.io/docs/reference/timber-postpreview/). I’ve tried modifying the PostQuery object but I’m not sure how to modify a PHP iterable object. I’ve tried
{{ function('the_excerpt') }}
but I run into problems trying to use a WordPress filter to modify the excerpt.
Suggestions? Thanks!
]]>I recently also though it might a good idea to use Twig in a plugin. However I soon realized that this is not a good idea:
https://www.ads-software.com/support/topic/fatal-error-after-last-update-on-13-06-2022/
The support case is in German. Summary: Lightbox with PhotoSwipe got a problem since Publish Press also uses Twig, but in a different version. However since there is only one namespace for Twig, this will cause major problems.
How did you solve this? Or would your plugin get the same problems when using along with Publish Press?
]]>There is an issue in Routers.php file after updating to 6.0 WP version and Timber Plugin.
Using the “\Routes::map()” and “\Routes::load” function in routers.php.
But not getting post’s data in the “account_controller”, tried using “\Timber::query_post()” and “new \Timber\Post()” functions to fetch post’s data but both of them are not working.
Can you please help me to solve this issue?
Routers.php code:
\Routes::map('/profile',function($params){
$query = sprintf('posts_per_page=1&post_status=publish&post_type=%s&name=%s','page','profile');
$params['action'] = 'viewUserProfileAction';
$params['controller'] = 'account_controller';
\Routes::load(self::HANDLER, $params, $query, 200);
});
account_controller.php code:
$p = \Timber::query_post(); //new \Timber\Post();
I’m surprised I’m the first person to try and do this, but I can find any working examples of how to do this. How do I display the WooCommerce gallery images in my twig template? I can display the product details which contains everything including the IDs of the gallery images but I cant get just the gallery image IDs on their own. Any help appreciated.
]]>Hi.
I want to get and set the value of an ACF field into a variable in my home.php file and then use this as part of a query.
So, for example, if a user enters the word ‘event’ in the the field ‘cat_name’ in the CMS, I wanted to get and set this as a variable and then use this as part of a basic query to return all posts with a category of event..
What I have at the moment is below. How do I get the value of get_field(‘cat_name’) and then store it in the $my_var variable. Is this possible?
<?php
$context = Timber::get_context();
$context['post'] = new Timberpost();
$my_var = get_field('cat_name');
$context['posts'] = Timber::get_posts(array(
'post_type' => 'post',
'category_name' => $my_var
));
Timber::render('home.twig', $context);
?>
]]>
Hello Team…
I’m managing this website for a client and the links (They say Show) are disoriented. I wanted to try and perform the upgrade but noticed the ominous warning on the plugin page. Can you tell me if this issue is related to using an old version of Timber?
Hi,
On my server running with php8 and WP 5.9, I get the following error message:
Deprecated: Required parameter $lineno follows optional parameter $only in …wp-content\plugins\timber-library\vendor\twig\twig\src\Node\IncludeNode.php on line 25
Can you please let me know if you plan an update of Twig in your plugin to fix this issue?
Or do you have any advice to fix this problem on my side, or at least hide this message, which is displayed in front…?
Thank you!
]]>Hi
IS Timber latest version is compatible with WordPress 5.9 or PHP 8 version?
Thanks,
Khalid
Hi,
We are using timber plugin on our website. I recently upgraded to latest version of WordPress and PHP and after upgrading to PHP 8.0. Few pages of the websites started throwing fatal error. All the errors points to the twig files and when I downgraded to php 7.4 everything started working fine. So I’m assuming it is a compatibility issue. Could you please guide me what can be done in this situation? cause I can’t keep old php version for long. It will automatically upgrade at some point.
]]>Hi,
You need to change your links to sensiolabs.org on the plugin page as they are no longer valid.
Twig is at twig.symfony.com
All the best,
Anthony
]]>Hi,
I’m currently trying to output the content of an SVG file that contains JavaScript and for some reasons, Timbers automatically encodes the ampersand & character to &. This is really problematic because it creates a bunch of JavaScript error. It seems that Twig by itself correctly output the contents but this is not the case with Timber. Any way around this issue ?
Thanks
]]>Hi,
Since 3 days !!! I try to have show only the select taxonomies and tag taxonomies that have a post, but I
Example. In a correct loop in home page I��m showing all posts categories XXX like this (and it��s working and not problem with that):
CATEGORY 1
Title
Img
FiedText
(and here I want the list of select taxonomies/tag-taxonomy-1 – tag-taxonomy-2 have current post and not showing all the taxonomies and all the tags taxonomies)
Example: if I have 2 taxonomies. Monuments and gastronomy.
In Monuments taxonomy, I have tags: houses, churchs, temples, etc. And choose only Monuments Taxonomy for this pots and only one tag churches.
We will see
CATEGORY 1
Title
Image
Field text
Monuments houses, churches, temples – Gastronomy Wine, food, meat, vegetable
and i want :
CATEGORY 1
Title
Image
Field text
Monuments/churches
Someone can help me and put example code php and twig. I��m so tired don��t find the soluce.
note: where is the best and active forum timber twig wordpress?
]]>There is compatibility problem with the Flowfact Plugin. Both plug-ins use Twig as template engine.
FLOWFACT WP Connector
If you open for example the object detail view or the overview, the loading of the current page takes over a minute.
If you do not load Timber for the respective page, the error disappears.
This makes the plug-in unusable for all my pages.
Does anyone have an idea how to work around this problem?
I am trying to create a custom page template in WordPress, using Timber/Twig.
I have used the following code and do not understand why it’s not working. Timber docs don’t provide specific examples.
I have a file named template-form-template.php, to be used for several form pages. I prefer to select the template in admin rather than creating a page-…twig for each page slug.
<?php
/**
* Template Name: Form Template
* Description: Use this template for custom forms.
*/
$context = Timber::context();
$context['post'] = new Timber\Post();
Timber::render( 'page-form.twig', $context );
?>
The template name appears as expected in WordPress admin. However, the page-form.twig is not being called. I have a shortcode in the page I’m testing, which appears as a raw shortcode, meaning the page content is being shown but with no twig formatting.
page-form.twig content is:
{% extends "base.twig" %}
{% block content %}
<div class="content-wrapper">
<article class="post-type-{{post.post_type}}" id="post-{{post.ID}}">
<section class="article-content">
<h1 class="article-h1">page.twig{{post.title}}Foooo</h1>
<div class="article-body">
{{post.content}}
</div>
</section>
</article>
</div>
<!-- /content-wrapper -->
{% endblock %}
The site is built and functioning already. I just want to add a generic template option.
]]>If you discover issues or are looking for help with Timber please do not post here. We have an active community on GitHub:
https://github.com/timber/timber
There you’ll find information on bug reports, discussions, in-progress features, coupon codes and more!
]]>