I have a custom field that is an entity reference, when using

print render($content['field_call_to_action_1']);

in a content type template it prints out the title Call to Action 1, and the Title of the content that the entity reference is linked too.

How can I just get it to print out the NID instead?

Thanks for your time!

1 Answer 1


$content is to be rendered and obeys what you have set in node(other other entity) type's Display Settings (Administer > Structure >Content Types).

What you should use is, $node object.


Now you will see a nicely formatted information of $node object which also has the NID you want.

You will be able to access it with this:


Quick hint:If you are trying to build a URL link from this value, have a look at url() and l() functions!

  • 1
    I don't know is it just my case, but it didn't worked for me. I used 'target_id' instead of 'nid' and worked fine. Commented Jan 9, 2013 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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