Paste the following code in your theme’s functions.php:
/* Describe what the code snippet does so you can remember later on */ add_action('wp_head', 'your_function_name'); function your_function_name(){ ?> PASTE HEADER CODE HERE <?php };
Add description (comment above the code snippet) and change the function’s name (two locations). Then add the desired code replacing “PASTE HEADER CODE HERE”.
Source: https://kinsta.com/knowledgebase/add-code-wordpress-header-footer/