New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When fetching an ACF field that returns WP_Post objects, convert them to Timber\Post #2981
Comments
I think |
D'oh, you're right, that's perfect. Sorry to bother! |
This doesn't seem to handle it well when an ACF field that would be converted is empty:
The WP_Error in question is simply |
In TermFactory.php, the
Looks like maybe that EDIT Or perhaps we should check |
Hi @75th , Are you willing to create a PR for handling that specific behavior? |
What I can see is that get_term only throws an error if the taxonomy does not exist. Was that your case as well @75th ? |
Problem
I'm on a project right now that fetches post reference ACF fields all over the place. These are returned as WP_Post objects (or lists thereof). This creates problems when the same template is sent the results of a Timber query in one place and ACF references in another; for instance, if a template gets a WP_Post, it has to use
post.permalink
, but if it gets a Timber\Post, it has to usepost.link
.Solution
Timber\Post::meta()
should convert anyWP_Post
objects it fetches intoTimber\Post
objects.Alternatives
Timber\Post
could implement the same interface asWP_Post
alongside its own stuff, so developers don't have to care as much which kind of object they get. But I'm pretty sure some of those things have been deprecated and removed in the past. (Could be wrong.)The text was updated successfully, but these errors were encountered: