{"id":2903,"date":"2021-11-01T12:48:36","date_gmt":"2021-11-01T12:48:36","guid":{"rendered":"https:\/\/elementor.com\/resources\/?p=2903"},"modified":"2021-11-01T12:48:36","modified_gmt":"2021-11-01T12:48:36","slug":"what-is-the-functions-php-file-in-wordpress","status":"publish","type":"post","link":"https:\/\/elementor.com\/resources\/glossary\/what-is-the-functions-php-file-in-wordpress\/","title":{"rendered":"What Is The functions.php File in WordPress?"},"content":{"rendered":"\n<p>The <strong>functions.php file<\/strong>, or theme functions file, is a template included in WordPress themes. The <strong>functions.php file<\/strong> behaves like a <a href=\"https:\/\/elementor.com\/blog\/best-free-wordpress-plugins\/\">WordPress plugin<\/a>, adding functionality and features to a <a href=\"https:\/\/elementor.com\/blog\/famous-wordpress-websites\/\">WordPress site<\/a>. The file automatically activates with the current theme and uses&nbsp;PHP&nbsp;code to change default features or add new ones.<\/p>\n\n\n\n<p>Editing the functions.php file with custom codes allows you to enhance your site with taxonomies, shortcodes, <a href=\"https:\/\/elementor.com\/blog\/wordpress-custom-post-types\/\">post types<\/a>, and more. For instance, a <a href=\"https:\/\/elementor.com\/resources\/free-wordpress-themes\/\">WP theme<\/a> might add some code to the theme\u2019s functions.php file to add a custom welcome message or a new&nbsp;widget&nbsp;area to the footer of the dashboard.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Functions.php vs WordPress Plugins<\/strong><\/h2>\n\n\n\n<p>There are advantages and compromises to using a functions.php rather than a WordPress plugin<\/p>\n\n\n\n<p>A&nbsp;functions.php&nbsp;file:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Requires no unique header text<\/li><li>Is stored in the theme&#8217;s subdirectory in wp-content\/themes<\/li><li>Executes only when in the active theme\u2019s directory<\/li><li>Applies only to that <a class=\"wpil_keyword_link\" href=\"https:\/\/elementor.com\/library\/\"   title=\"theme\" data-wpil-keyword-link=\"linked\">theme<\/a> (if the theme is changed, you can no longer use the features)&nbsp;<\/li><li>Can have numerous blocks of code used for many purposes<\/li><\/ul>\n\n\n\n<p>A WordPress plugin:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Requires specific, unique header text<\/li><li>Is stored in wp-content\/plugins, usually in a subdirectory<\/li><li>Only executes on page load when activated<\/li><li>Applies to all themes<\/li><li>Should have a single purpose \u2013 e.g.,&nbsp;offer SEO features or help with backups<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Take Note: Use functions.php With Caution<\/strong><\/h3>\n\n\n\n<p>If you decide to edit your functions.php file, use utmost caution for the following reasons:&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>First, edits to the functions file will be lost when the theme is updated.<\/li><li>Second, modifications will be lost if you change your WordPress theme.<\/li><li>Finally, making coding errors in the functions file can lock you out of your site.<\/li><\/ul>\n\n\n\n<p>Making a coding mistake, even something as simple as a missing semicolon could make your entire site disappear with the \u201cWhite Screen of Death\u201d error and other WP errors. Only edit a functions.php file if you have a child theme, and the code snippets will only be used with the active child theme. For example, you may want to include snippets for&nbsp;stylesheets, custom fonts or add a language translation file for that particular child theme<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The functions.php file, or theme functions file, is a template included in WordPress themes<\/p>\n","protected":false},"author":1292159,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_angie_page":false,"page_builder":"","footnotes":""},"categories":[15,31],"tags":[16],"class_list":["post-2903","post","type-post","status-publish","format-standard","hentry","category-glossary","category-wordpress","tag-build"],"acf":[],"_links":{"self":[{"href":"https:\/\/elementor.com\/resources\/wp-json\/wp\/v2\/posts\/2903","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elementor.com\/resources\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elementor.com\/resources\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elementor.com\/resources\/wp-json\/wp\/v2\/users\/1292159"}],"replies":[{"embeddable":true,"href":"https:\/\/elementor.com\/resources\/wp-json\/wp\/v2\/comments?post=2903"}],"version-history":[{"count":1,"href":"https:\/\/elementor.com\/resources\/wp-json\/wp\/v2\/posts\/2903\/revisions"}],"predecessor-version":[{"id":2904,"href":"https:\/\/elementor.com\/resources\/wp-json\/wp\/v2\/posts\/2903\/revisions\/2904"}],"wp:attachment":[{"href":"https:\/\/elementor.com\/resources\/wp-json\/wp\/v2\/media?parent=2903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elementor.com\/resources\/wp-json\/wp\/v2\/categories?post=2903"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elementor.com\/resources\/wp-json\/wp\/v2\/tags?post=2903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}