I have an entity reference field to a content type blog. I referenced a specific blog, but when I render that field in twig using {{ content.field_blog }}. I want to get the autor name and time when that blog was created - not the blog's name by default. Field is in paragraph. I would like to do this using twig, so without any preprocesses.

How can I do that?

  • View mode of the referenced entity? – Kevin May 30 '19 at 12:16

You should be able to get the author like this:

{{ paragraph.field_blog.entity.Owner.name.value }}

and the creation:

{{ paragraph.field_blog.entity.createdtime|format_date('medium') }}
  • I tried that, it's not rendering anything :/ On createdtime it throws exception "the timestamp must be numeric"... – LillyD May 30 '19 at 11:56
  • Try paragraph instead of content – user72672 May 30 '19 at 11:56
  • It works great @Jdrupal, thank you! – LillyD May 30 '19 at 12:01
  • Quick question, it renders for all three fields even tho one field is not referenced to, do you know why is that and how can i remove that line? – LillyD May 30 '19 at 12:03
  • I think that I have to see some code to help you – user72672 May 30 '19 at 12:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.