Timber: Theme class not fetching the right directory?

I am new to using Timber, but I’ve wanted a way to use Twig inside WordPress and ran across Timber, so I’m really excited!

To note, I’m also using the starter theme provided by Timber.

In playing around with things, I was starting out by just trying to set a logo image in base.twig. I added this line of code:

<img src="{{ theme.link }}/static/images/logo.png" />

This works as expected, except that the url given on output is:

<img src="https://domain.test/wp-content/themes/theme-name/theme/static/images/logo.png">

The issue to me is that theme.link goes one directory too deep. According to the documentation at https://timber.github.io/docs/reference/timber-theme/#link it should go to the root theme directory, but it’s not in my case.

Is there a way to set this or am I just missing something? Thanks in advance for your help!

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

@bocaj you’re doing everything right. Unfortunately, we made a tweak to the starter theme which caused some unanticipated errors like the one you’re seeing.

If you can simply move the contents of the /theme-name/theme/ folder into /theme-name/ (including style.css, functions.php and others) the problem will resolve itself and links/paths will behave as expected.

We tried to clean up the organization in a recent update. While it’s cleaner, it caused this problem. I’m in the process of rectifying this so it won’t lead to errors/questions in the future. Sorry for the confusion!


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x