{"id":1099,"date":"2018-12-13T16:40:54","date_gmt":"2018-12-13T16:40:54","guid":{"rendered":"http:\/\/blog.silverterra.net\/?p=1099"},"modified":"2018-12-13T17:52:39","modified_gmt":"2018-12-13T17:52:39","slug":"wordpress-add-functions-safe-method","status":"publish","type":"post","link":"https:\/\/blog.silverterra.net\/?p=1099","title":{"rendered":"WordPress add functions &#8211; safe method"},"content":{"rendered":"<blockquote><p>Goal: add own functions to the wordpress site<\/p><\/blockquote>\n<p>Forget the <b>functions.php<\/b>! Frankly this is working only until the next update :(.<\/p>\n<p>My way is to create a totally separated file with the added functions:<br \/>\n1. Let&#8217;s create a new file <b>functions_added.php<\/b><\/p>\n<pre data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">\r\n&lt;?php\r\nfunction fnc_001( $param, ... ) {\r\n...\r\n}\r\n...\r\nfunction fnc_nnn( $param, ... ) {\r\n...\r\n}\r\n<\/pre>\n<p>Never put php close tag <span style=\"color:#f00\">?&gt;<\/span> to the end of the file!<\/p>\n<p>2. Put this file into the theme main directory.<\/p>\n<p>3. Link this file to the theme <b>header.php<\/b> file. Add the following to the start of the header file.<\/p>\n<pre data-enlighter-language=\"php\" class=\"EnlighterJSRAW\">\r\n&lt;?php\r\nrequire (get_template_directory() . '\/' . 'functions_added.php' );\r\n?&gt;&lt;!DOCTYPE html...\r\n<\/pre>\n<p>This is it. All my new functions are in a safe place now.<\/p>\n<div class=\"zoomer\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/blog.silverterra.net\/wp-content\/uploads\/2018\/12\/IMG_20181213_155042-300x155.jpg\" alt=\"\" width=\"300\" height=\"155\" class=\"alignnone size-medium wp-image-1116\" \/><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Goal: add own functions to the wordpress site Forget the functions.php! Frankly this is working only until the next update :(. My way is to create a totally separated file with the added functions: 1. Let&#8217;s create a new file functions_added.php Never put php close tag ?&gt; to the end of the file! 2. Put [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,4],"tags":[],"class_list":["post-1099","post","type-post","status-publish","format-standard","hentry","category-tricky","category-wordpress"],"_links":{"self":[{"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/posts\/1099","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1099"}],"version-history":[{"count":4,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/posts\/1099\/revisions"}],"predecessor-version":[{"id":1104,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=\/wp\/v2\/posts\/1099\/revisions\/1104"}],"wp:attachment":[{"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1099"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1099"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.silverterra.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1099"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}