Skip to content

Accessing another Translatable Field #402

Answered by aaronmeder
DavidZudu asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @DavidZudu

yes, you can do this easily:

inside your components functions.php file:

add_filter('Flynt/addComponentData?name=Bar', function ($data) {
    $data['trans'] = Options::getTranslatable('Foo');
    return $data;
});

Then inside your twig file you can use {{ trans.X }} to access the translation. If you cannot access the value try to use {{ dump(trans) }} to see if the data is nested or similar.

Hint: you need to have define( 'WP_DEBUG', true ); in your site's wp-config.php to see the dump values.

Hope that helps.
Aaron

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by DavidZudu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants