How to change search placeholder? So far I have tried this code in mytheme.theme:

function mytheme_form_search_block_form_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
    $form['keys']['#attributes']['placeholder'] = t('Custom wording');
}


And this one:

function mytheme_form_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if ($form_id == 'search_block_form') { 
    $form['keys']['#attributes']['placeholder'] = t('Custom wording');
  }
}


Also this one:

function mytheme_form_search_block_form_alter(&amp;$form, $form_state) {
    $form['keys']['#attributes']['placeholder'] = t('Custom wording');
}


Site is not crashing, but nothing happens on the placeholder. 

I have based these 3 snippets on these pages:


https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Form%21form.api.php/function/hook_form_FORM_ID_alter/8.5.x
How to replace the search submit button with a Font Awesome character?
This code should create the placeholder:

function mytheme_form_search_block_form_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  $form['keys']['#attributes']['placeholder'] = t('The new placeholder');
}


So if that does not work for you, it might be because you need to clear the cache.