{"id":54997,"date":"2020-03-25T12:38:33","date_gmt":"2020-03-25T11:38:33","guid":{"rendered":"https:\/\/samuelchopard.ch\/wiki\/?p=54997"},"modified":"2020-03-25T12:39:43","modified_gmt":"2020-03-25T11:39:43","slug":"how-to-add-code-to-head-via-functions-php","status":"publish","type":"post","link":"https:\/\/samuelchopard.ch\/wiki\/library\/how-to-add-code-to-head-via-functions-php\/","title":{"rendered":"How to add code to head (via functions.php)"},"content":{"rendered":"<p><!--more--><br \/>\nPaste the following code in your theme&#8217;s <em>functions.php<\/em>:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">\/* Describe what the code snippet does so you can remember later on *\/\r\nadd_action('wp_head', 'your_function_name');\r\nfunction your_function_name(){\r\n?&gt;\r\nPASTE HEADER CODE HERE\r\n&lt;?php\r\n};<\/pre>\n<p>Add description (comment above the code snippet) and change the function&#8217;s name (two locations). Then add the desired code replacing &#8220;PASTE HEADER CODE HERE&#8221;.<\/p>\n<p>Source: <a target=\"_blank\" href=\"https:\/\/kinsta.com\/knowledgebase\/add-code-wordpress-header-footer\/\">https:\/\/kinsta.com\/knowledgebase\/add-code-wordpress-header-footer\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"Paste the following code in your theme's functions.php: \/* Describe what the code snippet does so you can remember later [...]","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[375,373,372,374],"class_list":["post-54997","post","type-post","status-publish","format-standard","hentry","category-php-tricks","tag-analytics","tag-code","tag-head","tag-tracking"],"_links":{"self":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54997","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/comments?post=54997"}],"version-history":[{"count":2,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54997\/revisions"}],"predecessor-version":[{"id":54999,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54997\/revisions\/54999"}],"wp:attachment":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/media?parent=54997"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/categories?post=54997"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/tags?post=54997"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}