1

I am trying below code to get node field value into template.php.

$field_items = field_get_items('node', $node, 'field_read_more_title');
$variables['readmoretitle'] = $field_items[0]['value'];

But $variables['readmoretitle'] is empty for published node, for unpublished node I am getting correct value.

How can I get the published node field value in template.php?

3
  • What function are you doing this code?
    – GwenM
    Commented Jan 28, 2016 at 10:18
  • In hook_preprocess_node(). Commented Jan 28, 2016 at 11:02
  • Can you copy the whole function?
    – GwenM
    Commented Jan 28, 2016 at 13:33

1 Answer 1

0

The right way to doing this is hook_node_view_alter(&$build) where you can alter teaser link or any other $links. You reference from here

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.