How to access fields of a component from a BlockPostObject component? #421
-
Hello, And if I try to display any content via I definitely miss something and I can't see. So basically my question is, how can I access specific components and their fields from another I hope this is clear enough :) Thank you for your help! Marco |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @marcotiberio , Let's say you have a page. On that page is a flexible content field. You have a component BlockArtistInfo in which you select a different post, maybe of post type artist through a ACF relationship or post_object field. And for this connected post, you want to access the meta fields. The challenge is that when you use What we usually do in the add_filter('Flynt/addComponentData?name= BlockArtistInfo', function ($data) {
$data['item'] = new \Timber\Post($data['item']);
return $data;
}); if item is the relation field name. Then you can do the following it you twig file {{ item.meta('bioHtml') }} or something similar. Let me know if that helps you. |
Beta Was this translation helpful? Give feedback.
Hi @marcotiberio ,
I do not get a full picture of your setup or what you are trying to do exactly. So I will make a couple of assumptions and try to provide a solution. Please correct if I got something wrong.
Let's say you have a page. On that page is a flexible content field. You have a component BlockArtistInfo in which you select a different post, maybe of post type artist through a ACF relationship or post_object field. And for this connected post, you want to access the meta fields.
The challenge is that when you use
'return_format' => 'object'
in ACF's relation fields, it returns a regular WordPress post object. Not a TimberPost. So you cannot use the methods you are used to with T…