{"id":1829,"date":"2024-09-26T13:44:51","date_gmt":"2024-09-26T13:44:51","guid":{"rendered":"http:\/\/docs"},"modified":"2024-09-27T07:38:41","modified_gmt":"2024-09-27T07:38:41","password":"","slug":"where-do-i-add-my-custom-php-code","status":"publish","type":"docs","link":"https:\/\/www.8theme.com\/documentation\/xstore\/additional-customisation\/where-do-i-add-my-custom-php-code\/","title":{"rendered":"Where do I add my custom PHP code?"},"content":{"rendered":"<div data-html-block=\"\">\n<section class=\"index-list\">\n<h3><span style=\"color: revert; font-size: revert; font-weight: revert; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;\">Inside the child theme<\/span><\/h3>\n<\/section>\n<\/div>\n<p>The best way to add your custom PHP code (small snippets) is in the <code class=\"inline-code\">functions.php<\/code> file of your child theme: <code class=\"inline-code\">wp-content\/themes\/xstore-child\/functions.php<\/code><\/p>\n<p>The functions file behaves like a WordPress Plugin, adding features and functionality to a WordPress site through PHP code. You can use it to call native PHP functions, WordPress functions, or to define your own functions.<\/p>\n<div data-html-block=\"\">\n<div data-html-block=\"\">\n<div>\n<p class=\"callout-yellow dashed\"><strong>Note:<\/strong> It is strongly advised to refrain from inserting PHP code in the <code class=\"inline-code\">functions.php<\/code> file of the parent theme under any circumstances. To ensure that your customizations persist during theme updates, it is <strong>always<\/strong> recommended to utilize the <code class=\"inline-code\">functions.php<\/code> file of your child theme.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<h3>By plugin<\/h3>\n<p>Alternatively,\u00a0simply use a &#8220;functionality&#8221; plugin such as the\u00a0<a href=\"https:\/\/wordpress.org\/plugins\/code-snippets\/\" target=\"_blank\" rel=\"nofollow noopener\">Code Snippets<\/a>\u00a0plugin to manage your custom PHP snippets.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Inside the child theme The best way to add your custom PHP code (small snippets) is in the functions.php file of your child theme: wp-content\/themes\/xstore-child\/functions.php The functions file behaves like a WordPress Plugin, adding features and functionality to a WordPress site through PHP code. You can use it to call native PHP functions, WordPress functions, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"doc_category":[42],"doc_tag":[],"class_list":["post-1829","docs","type-docs","status-publish","hentry","doc_category-additional-customisation"],"aioseo_notices":[],"year_month":"2026-04","word_count":132,"total_views":"2865","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"author_nicename":"docs","author_url":"https:\/\/www.8theme.com\/documentation\/author\/docs\/"},"doc_category_info":[{"term_name":"Additional Customization","term_url":"https:\/\/www.8theme.com\/documentation\/xstore\/additional-customisation\/"}],"doc_tag_info":[],"author_list":[{"ID":"1","user_login":"docs","display_name":"docs","id":"1"}],"knowledge_base_info":[],"knowledge_base_slug":[],"_links":{"self":[{"href":"https:\/\/www.8theme.com\/documentation\/wp-json\/wp\/v2\/docs\/1829","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.8theme.com\/documentation\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.8theme.com\/documentation\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.8theme.com\/documentation\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.8theme.com\/documentation\/wp-json\/wp\/v2\/comments?post=1829"}],"version-history":[{"count":1,"href":"https:\/\/www.8theme.com\/documentation\/wp-json\/wp\/v2\/docs\/1829\/revisions"}],"predecessor-version":[{"id":1951,"href":"https:\/\/www.8theme.com\/documentation\/wp-json\/wp\/v2\/docs\/1829\/revisions\/1951"}],"wp:attachment":[{"href":"https:\/\/www.8theme.com\/documentation\/wp-json\/wp\/v2\/media?parent=1829"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/www.8theme.com\/documentation\/wp-json\/wp\/v2\/doc_category?post=1829"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.8theme.com\/documentation\/wp-json\/wp\/v2\/doc_tag?post=1829"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}