{"id":11736,"date":"2023-01-18T07:53:25","date_gmt":"2023-01-18T07:53:25","guid":{"rendered":"https:\/\/nieuw.wpprovider.nl\/custom-code-where-do-i-place-this-in-wordpress\/"},"modified":"2024-08-14T06:07:17","modified_gmt":"2024-08-14T06:07:17","slug":"custom-code-where-do-i-place-this-in-wordpress","status":"publish","type":"post","link":"https:\/\/nieuw.wpprovider.nl\/en\/custom-code-where-do-i-place-this-in-wordpress\/","title":{"rendered":"Custom code where do I place this in WordPress?"},"content":{"rendered":"<p>Whether you&#8217;re a pro or just starting to customize your WordPress site, it&#8217;s important to know where to place your custom code \/ code snippets.<br \/>\nIt can make a big difference in performance and maintenance.<br \/>\nIn this post, we&#8217;ll discuss three ways to add custom code to your site so you can choose the method that best suits you and your particular situation.<br \/>\nLet&#8217;s take a look at our options.     <\/p>\n<h2>1. Make use of a Code snippet plugin<\/h2>\n<p>  The Code Snippets plugin is a good option for those less familiar with code.<br \/>\nThe plugin is easy to use, free to install and manage directly from the WordPress admin.<br \/>\nWith this plugin, you can easily add code snippets, enable and disable them as needed, without worrying about errors.<br \/>\nTo get started, go to Plugins &gt; New plugin and search for &#8220;Code Snippets.&#8221; <img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-5923 size-full\" src=\"https:\/\/nieuw.wpprovider.nl\/wp-content\/uploads\/Schermafbeelding-2023-01-18-om-08.41.17.png\" alt=\"\" width=\"578\" height=\"380\" srcset=\"https:\/\/nieuw.wpprovider.nl\/wp-content\/uploads\/Schermafbeelding-2023-01-18-om-08.41.17.png 578w, https:\/\/nieuw.wpprovider.nl\/wp-content\/uploads\/Schermafbeelding-2023-01-18-om-08.41.17-300x197.png 300w\" sizes=\"(max-width: 578px) 100vw, 578px\" \/> Once the plugin is installed and activated, you can go to Snippets &gt; Add New to create a new snippet.<br \/>\nGive it a name, paste the code and you&#8217;re done. <img decoding=\"async\" class=\"alignnone wp-image-5926 size-full\" src=\"https:\/\/nieuw.wpprovider.nl\/wp-content\/uploads\/Code-snippets.png\" alt=\"\" width=\"2880\" height=\"1800\" srcset=\"https:\/\/nieuw.wpprovider.nl\/wp-content\/uploads\/Code-snippets.png 2880w, https:\/\/nieuw.wpprovider.nl\/wp-content\/uploads\/Code-snippets-300x188.png 300w, https:\/\/nieuw.wpprovider.nl\/wp-content\/uploads\/Code-snippets-1024x640.png 1024w, https:\/\/nieuw.wpprovider.nl\/wp-content\/uploads\/Code-snippets-768x480.png 768w, https:\/\/nieuw.wpprovider.nl\/wp-content\/uploads\/Code-snippets-1536x960.png 1536w, https:\/\/nieuw.wpprovider.nl\/wp-content\/uploads\/Code-snippets-2048x1280.png 2048w\" sizes=\"(max-width: 2880px) 100vw, 2880px\" \/> In the Snippets section &gt; All snippets, you&#8217;ll find a switch that allows you to enable and disable specific snippets as needed. <img decoding=\"async\" class=\"alignnone wp-image-5931 size-full\" src=\"https:\/\/nieuw.wpprovider.nl\/wp-content\/uploads\/Code-snippet2.png\" alt=\"\" width=\"2880\" height=\"1800\" srcset=\"https:\/\/nieuw.wpprovider.nl\/wp-content\/uploads\/Code-snippet2.png 2880w, https:\/\/nieuw.wpprovider.nl\/wp-content\/uploads\/Code-snippet2-300x188.png 300w, https:\/\/nieuw.wpprovider.nl\/wp-content\/uploads\/Code-snippet2-1024x640.png 1024w, https:\/\/nieuw.wpprovider.nl\/wp-content\/uploads\/Code-snippet2-768x480.png 768w, https:\/\/nieuw.wpprovider.nl\/wp-content\/uploads\/Code-snippet2-1536x960.png 1536w, https:\/\/nieuw.wpprovider.nl\/wp-content\/uploads\/Code-snippet2-2048x1280.png 2048w\" sizes=\"(max-width: 2880px) 100vw, 2880px\" \/> Within the plugin, it is also easily possible to export code snippets in order to then import them into another WordPress website.<br \/>\nIn the future, there will also be a Cloud version for this that will allow you to easily share code snippets with other WordPress sites.<br \/>\nWhile this is the easiest way to use PHP code snippets on your WordPress website, there are other options that require a bit more knowledge, such as connecting to the website via FTP.        <\/p>\n<h2>2. Create your own plugin for your code snippets<\/h2>\n<p>  This method is aimed more at developers and offers a number of advantages, such as the fact that snippets are not stored in a database, but are directly in the code where they are intended. To use this method, simply create an empty .php file in the wp-content\/plugins folder. The contents of the file should look like this:  <\/p>\n<pre>&lt;?php\n\/*\n* Plugin name: Naam van jouw code\n* Description: Omschrijving van wat de code doet\n*\/\n\nif ( ! defined( 'ABSPATH' ) ) {\nexit;\n}\n\n\/\/ Onderstaand kun je jouw code plaatsen\n<\/pre>\n<h2>3. Placement in the functions.php of your theme<\/h2>\n<p>  A third way to add custom code to your WordPress website is to place it in the functions.php of your active theme.<br \/>\nThis file is specifically for adding or modifying functionalities to your WordPress website, such as adding new shortcodes, creating widgets or creating custom features.<br \/>\nIt is important to note that the code you add to the functions.php is executed on every page of the site.<br \/>\nThis can affect the performance of your site, so it is recommended to add only the code that is really needed.<br \/>\nWhen changing or updating the theme, the code you added in the functions.php may be lost.<br \/>\nTherefore, it is recommended that you also save the code you add in an external file so that you can easily restore it when needed.<br \/>\nIf you are not so experienced with working with code, we recommend backing up the current functions.php first, so you can restore it in case of errors.<br \/>\nAnd if you are not sure what you are doing, it is advisable to seek professional advice before making any changes to the functions.php file.       <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Whether you&#8217;re a pro or just starting to customize your WordPress site, it&#8217;s important to know where to place your custom code \/ code snippets. It can make a big difference in performance and maintenance. In this post, we&#8217;ll discuss three ways to add custom code to your site so you can choose the method [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":10895,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[12],"tags":[],"class_list":["post-11736","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-geen-onderdeel-van-een-categorie"],"acf":[],"_links":{"self":[{"href":"https:\/\/nieuw.wpprovider.nl\/en\/wp-json\/wp\/v2\/posts\/11736","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nieuw.wpprovider.nl\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nieuw.wpprovider.nl\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nieuw.wpprovider.nl\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nieuw.wpprovider.nl\/en\/wp-json\/wp\/v2\/comments?post=11736"}],"version-history":[{"count":1,"href":"https:\/\/nieuw.wpprovider.nl\/en\/wp-json\/wp\/v2\/posts\/11736\/revisions"}],"predecessor-version":[{"id":11776,"href":"https:\/\/nieuw.wpprovider.nl\/en\/wp-json\/wp\/v2\/posts\/11736\/revisions\/11776"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nieuw.wpprovider.nl\/en\/wp-json\/wp\/v2\/media\/10895"}],"wp:attachment":[{"href":"https:\/\/nieuw.wpprovider.nl\/en\/wp-json\/wp\/v2\/media?parent=11736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nieuw.wpprovider.nl\/en\/wp-json\/wp\/v2\/categories?post=11736"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nieuw.wpprovider.nl\/en\/wp-json\/wp\/v2\/tags?post=11736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}