How to print entity referenced fields (node) title in node.tpl.php? I want to print an entity referenced fields (node) title in node--customtype.tpl.php.
&lt;?php print render($content['field_my_entity_reference']); ?&gt; prints the field with some CSS class as below:
&lt;div class=&quot;field-items&quot;&gt;
&lt;div class=&quot;field-item even&quot;&gt;
&lt;a href=&quot;/node/11&quot;&gt;Entity Title&lt;/a&gt;
&lt;/div&gt;
&lt;/div&gt;


What I want to do is to print this field without any pre-defined CSS classes etc..
[field_my_entity_reference] =&gt; Array
        (
            [und] =&gt; Array
                (
                    [0] =&gt; Array
                        (
                            [target_id] =&gt; 11
                            [entity] =&gt; stdClass Object
                                (
                                    [vid] =&gt; 41
                                    [uid] =&gt; 1
                                    [title] =&gt; Entity Title
                                    [log] =&gt; 
                                    [status] =&gt; 1
                                    [comment] =&gt; 1
                                    [promote] =&gt; 0
                                    [sticky] =&gt; 0
                                    [nid] =&gt; 11
                                    [type] =&gt; project
                                    [language] =&gt; es
                                    [created] =&gt; 1466009429
                                    [changed] =&gt; 1466502663
                                    [tnid] =&gt; 0
                                    [translate] =&gt; 0
                                    [revision_timestamp] =&gt; 1466502663
                                    [revision_uid] =&gt; 1
                                    [body] =&gt; Array
                                        (
                                            [und] =&gt; Array
                                                (
                                                    [0] =&gt; Array
                                                        (
                                                            [value] =&gt; 

I tried &lt;?php print $node-&gt;field_my_entity_reference['und'][0]['entity']['title']; ?&gt; but it gives error:

Fatal error: Cannot use object of type stdClass as array in


How can I print the title value of entity referenced field in node.tpl.php?
OK, without knowing anything about stdClass Object these kind of questions are normal :)

So, after reading a question about stdClass Object in SO I did what I want as below:

&lt;?php print $node-&gt;field_my_entity_reference['und'][0]['entity']-&gt;title; ?&gt;


This prints the title as plain text.

Note: Is there another way or better way you're always welcome.