How get access special field value? I want to get access to a special field value, do some processing or manipulating on it and then place it back in theme. For example, I've created a custom content type that name is "News" and has a field with below properties:


label: News Number 
machine name: news_num
value: Number (float)


I did content-type node theming with name node--news.html.twig, Now I want to understand Is there any preproccessing hook to modify or altering the field value and in addition I want to learn right way for manipulate the field value, I wrote something like below code:

ThemeName.theme:

function ThemeName_preprocess_node(&amp;$variables) {
// Get access to field value:
  $value = $variables['node']-&gt;news_num();
/**
* Makeing some manipulation on $value here.
*/
  $variables['value'] = $value;
}



The type of operation is not really important; I'm most looking for a solution to learn standard method and general format to access and modify the field value.
I just want to overview the field value (alter the field value before rendering) and not doing any override or change the field value in the database.


Any suggestions?
I suggest you two solution one based on what you tried to did 

First solution

in yourthemename.theme 

if ($variables['node']-&gt;getType() == 'YOUR_CONTENT_TYPE') {
    $variables['My_Field'] = $variables['node']-&gt;get('YOUR_FIELD')-&gt;value;
  }


and in your custom node template

   {{ My_Field }}



  Tips: Those of "YOUR_CONTENT_TYPE" and "YOUR_FIELD" are
  machine names for your content type and your content field.


Second solution

in your content type node template file ( I mean if your content type name is News in node--news.html.twig) try to add your custom value to it with:

  {% set My_Field = node.YOUR_FIELD.value
      {# Make your manipulation here #}
   %}
   {# And then print it back wherever you like with below code: #}
  {{ My_Field }}