{"id":16462,"date":"2024-01-26T08:11:41","date_gmt":"2024-01-26T08:11:41","guid":{"rendered":"https:\/\/www.webhosting.uk.com\/kb\/?p=16462"},"modified":"2024-12-26T06:20:33","modified_gmt":"2024-12-26T06:20:33","slug":"how-to-add-php-code-using-a-plugin","status":"publish","type":"post","link":"https:\/\/www.webhosting.uk.com\/kb\/how-to-add-php-code-using-a-plugin\/","title":{"rendered":"How to add PHP code using a plugin"},"content":{"rendered":"<p>WordPress has stopped users from adding code directly to prevent attacks. To insert PHP code safely in a post, convert it into a shortcode.<\/p>\n<p>You can create a shortcode manually in WordPress, but using a plugin makes it easier. Many plugins in the WordPress repository allow adding custom code.<\/p>\n<p>In this guide, we&#8217;ll use a popular option called WPCode-<\/p>\n<ol>\n<li>Log into WordPress.<br \/>\n<a href=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_152.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-16363\" src=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_152-273x300.png\" alt=\"WordPress Login\" width=\"273\" height=\"300\" srcset=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_152-273x300.png 273w, https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_152.png 347w\" sizes=\"auto, (max-width: 273px) 100vw, 273px\" \/><\/a><\/li>\n<li>Search for Plugins, and click on &#8220;Add New.&#8221;<br \/>\n<a href=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_187.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-16463 size-full\" src=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_187.png\" alt=\"Add new plugin\" width=\"331\" height=\"131\" srcset=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_187.png 331w, https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_187-300x119.png 300w\" sizes=\"auto, (max-width: 331px) 100vw, 331px\" \/><\/a><\/li>\n<li>Install &#8220;WPCode&#8221; and activate the plugin.<br \/>\n<a href=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_188.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-16464 size-full\" src=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_188.png\" alt=\"Install and activate the plugin.\" width=\"568\" height=\"266\" srcset=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_188.png 568w, https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_188-300x140.png 300w\" sizes=\"auto, (max-width: 568px) 100vw, 568px\" \/><\/a><\/li>\n<li>Go to Code Snippets, click &#8220;+Add Snippet&#8221; option to access a library of ready-made code snippets for specific functions.<br \/>\n<a href=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_189.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-16465\" src=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_189-300x275.png\" alt=\"Code Snippets\" width=\"300\" height=\"275\" srcset=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_189-300x275.png 300w, https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_189.png 326w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<li>Click the &#8220;Use Snippet&#8221; button under the &#8220;Add Your Custom Code (New Snippet)&#8221; option.<br \/>\n<a href=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_190.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-16466\" src=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_190-300x84.png\" alt=\" Add Your Custom Code\" width=\"300\" height=\"84\" srcset=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_190-300x84.png 300w, https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_190.png 402w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/li>\n<li>Type &#8220;Get Time Zone\u201d in the &#8220;Add title for snippet&#8221; field.<br \/>\n<a href=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_191.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-16467 size-large\" src=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_191-1024x126.png\" alt=\"Get Time Zone.\" width=\"1024\" height=\"126\" srcset=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_191-1024x126.png 1024w, https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_191-300x37.png 300w, https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_191-768x95.png 768w, https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_191.png 1142w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/li>\n<li>Set the Code Type using the dropdown menu, select &#8220;PHP Snippet&#8221;.<br \/>\n<a href=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_192.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-16468\" src=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_192.png\" alt=\"Code Type\" width=\"266\" height=\"202\" \/><\/a><\/li>\n<li>Name your new PHP code snippet and enter the code in the Code Preview box.<br \/>\n<a href=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_193.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-16469 size-full\" src=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_193.png\" alt=\"Code Preview\" width=\"551\" height=\"174\" srcset=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_193.png 551w, https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_193-300x95.png 300w\" sizes=\"auto, (max-width: 551px) 100vw, 551px\" \/><\/a><\/li>\n<li>Try Auto Insert and set the location to the Site Wide Footer.<br \/>\n<a href=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_194.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-16470 size-full\" src=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_194.png\" alt=\"Insert\" width=\"634\" height=\"468\" srcset=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_194.png 634w, https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_194-300x221.png 300w\" sizes=\"auto, (max-width: 634px) 100vw, 634px\" \/><\/a><\/li>\n<li>Turn on the toggle in the top menu to activate the code snippet.<br \/>\n<a href=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_195.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-16471 size-full\" src=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_195.png\" alt=\"TOGGLE\" width=\"1046\" height=\"53\" srcset=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_195.png 1046w, https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_195-300x15.png 300w, https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_195-1024x52.png 1024w, https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_195-768x39.png 768w\" sizes=\"auto, (max-width: 1046px) 100vw, 1046px\" \/><\/a><\/li>\n<li>Click on &#8220;Save Snippet.&#8221;<br \/>\n<a href=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_196.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-16472 size-full\" src=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_196.png\" alt=\"Shortcode\" width=\"1169\" height=\"65\" srcset=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_196.png 1169w, https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_196-300x17.png 300w, https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_196-1024x57.png 1024w, https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_196-768x43.png 768w\" sizes=\"auto, (max-width: 1169px) 100vw, 1169px\" \/><\/a><\/li>\n<li>Use Shortcode to simplify your code. Click Copy, then paste the shortcode on your chosen WordPress post or page.<br \/>\n<a href=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_197.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-16473 size-full\" src=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_197.png\" alt=\"Shortcode\" width=\"644\" height=\"395\" srcset=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_197.png 644w, https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_197-300x184.png 300w\" sizes=\"auto, (max-width: 644px) 100vw, 644px\" \/><\/a><\/li>\n<li>If you pick Auto Insert, you can make the PHP code run conditionally. In the free version, you get User and Page options like user role, page type, and specific URL. Add a new group, set the conditions, and click Update.<br \/>\n<a href=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_198.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-16474 size-full\" src=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_198.png\" alt=\"Update\" width=\"884\" height=\"406\" srcset=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_198.png 884w, https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_198-300x138.png 300w, https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_198-768x353.png 768w\" sizes=\"auto, (max-width: 884px) 100vw, 884px\" \/><\/a><\/li>\n<\/ol>\n<p>In this way, you can add PHP Code using a Plugin.<\/p>\n<p>Once you&#8217;ve installed any plugin, you can <a href=\"https:\/\/www.webhosting.uk.com\/kb\/how-to-set-up-auto-updates-for-wordpress-plugins\/\">Set up Auto-updates for WordPress plugins<\/a> to stay up-to-date and give your users a faster, smoother website experience.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress has stopped users from adding code directly to prevent attacks. To insert PHP code safely in a post, convert it into a shortcode. You can create a shortcode manually&hellip;<\/p>\n<p><a href=\"https:\/\/www.webhosting.uk.com\/kb\/how-to-add-php-code-using-a-plugin\/\" class=\"more-link\">Read More<\/a><\/p>\n<div class='heateorSssClear'><\/div><div  class='heateor_sss_sharing_container heateor_sss_horizontal_sharing' data-heateor-sss-href='https:\/\/www.webhosting.uk.com\/kb\/how-to-add-php-code-using-a-plugin\/'><div class='heateor_sss_sharing_title' style=\"font-weight:bold\" >Spread the love<\/div><div class=\"heateor_sss_sharing_ul\"><a aria-label=\"Facebook\" class=\"heateor_sss_facebook\" href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fwww.webhosting.uk.com%2Fkb%2Fhow-to-add-php-code-using-a-plugin%2F\" title=\"Facebook\" rel=\"nofollow noopener\" target=\"_blank\" style=\"font-size:32px!important;box-shadow:none;display:inline-block;vertical-align:middle\"><span class=\"heateor_sss_svg\" style=\"background-color:#0765FE;width:40px;height:40px;display:inline-block;opacity:1;float:left;font-size:32px;box-shadow:none;display:inline-block;font-size:16px;padding:0 4px;vertical-align:middle;background-repeat:repeat;overflow:hidden;padding:0;cursor:pointer;box-sizing:content-box\"><svg style=\"display:block;\" focusable=\"false\" aria-hidden=\"true\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 32 32\"><path fill=\"#fff\" d=\"M28 16c0-6.627-5.373-12-12-12S4 9.373 4 16c0 5.628 3.875 10.35 9.101 11.647v-7.98h-2.474V16H13.1v-1.58c0-4.085 1.849-5.978 5.859-5.978.76 0 2.072.15 2.608.298v3.325c-.283-.03-.775-.045-1.386-.045-1.967 0-2.728.745-2.728 2.683V16h3.92l-.673 3.667h-3.247v8.245C23.395 27.195 28 22.135 28 16Z\"><\/path><\/svg><\/span><\/a><a aria-label=\"X\" class=\"heateor_sss_button_x\" href=\"https:\/\/twitter.com\/intent\/tweet?text=How%20to%20add%20PHP%20code%20using%20a%20plugin&url=https%3A%2F%2Fwww.webhosting.uk.com%2Fkb%2Fhow-to-add-php-code-using-a-plugin%2F\" title=\"X\" rel=\"nofollow noopener\" target=\"_blank\" style=\"font-size:32px!important;box-shadow:none;display:inline-block;vertical-align:middle\"><span class=\"heateor_sss_svg heateor_sss_s__default heateor_sss_s_x\" style=\"background-color:#2a2a2a;width:40px;height:40px;display:inline-block;opacity:1;float:left;font-size:32px;box-shadow:none;display:inline-block;font-size:16px;padding:0 4px;vertical-align:middle;background-repeat:repeat;overflow:hidden;padding:0;cursor:pointer;box-sizing:content-box\"><svg width=\"100%\" height=\"100%\" style=\"display:block;\" focusable=\"false\" aria-hidden=\"true\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 32 32\"><path fill=\"#fff\" d=\"M21.751 7h3.067l-6.7 7.658L26 25.078h-6.172l-4.833-6.32-5.531 6.32h-3.07l7.167-8.19L6 7h6.328l4.37 5.777L21.75 7Zm-1.076 16.242h1.7L11.404 8.74H9.58l11.094 14.503Z\"><\/path><\/svg><\/span><\/a><a aria-label=\"Linkedin\" class=\"heateor_sss_button_linkedin\" href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=https%3A%2F%2Fwww.webhosting.uk.com%2Fkb%2Fhow-to-add-php-code-using-a-plugin%2F\" title=\"Linkedin\" rel=\"nofollow noopener\" target=\"_blank\" style=\"font-size:32px!important;box-shadow:none;display:inline-block;vertical-align:middle\"><span class=\"heateor_sss_svg heateor_sss_s__default heateor_sss_s_linkedin\" style=\"background-color:#0077b5;width:40px;height:40px;display:inline-block;opacity:1;float:left;font-size:32px;box-shadow:none;display:inline-block;font-size:16px;padding:0 4px;vertical-align:middle;background-repeat:repeat;overflow:hidden;padding:0;cursor:pointer;box-sizing:content-box\"><svg style=\"display:block;\" focusable=\"false\" aria-hidden=\"true\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 32 32\"><path d=\"M6.227 12.61h4.19v13.48h-4.19V12.61zm2.095-6.7a2.43 2.43 0 0 1 0 4.86c-1.344 0-2.428-1.09-2.428-2.43s1.084-2.43 2.428-2.43m4.72 6.7h4.02v1.84h.058c.56-1.058 1.927-2.176 3.965-2.176 4.238 0 5.02 2.792 5.02 6.42v7.395h-4.183v-6.56c0-1.564-.03-3.574-2.178-3.574-2.18 0-2.514 1.7-2.514 3.46v6.668h-4.187V12.61z\" fill=\"#fff\"><\/path><\/svg><\/span><\/a><\/div><div class=\"heateorSssClear\"><\/div><\/div><div class='heateorSssClear'><\/div>","protected":false},"author":35,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1885],"tags":[],"class_list":["post-16462","post","type-post","status-publish","format-standard","hentry","category-wordpress-hosting"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v28.3 (Yoast SEO v28.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to add PHP code using a plugin - WHUK<\/title>\n<meta name=\"description\" content=\"Easily add PHP code using a WordPress plugin for enhanced functionality. Explore our knowledge base for step-by-step guidance!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webhosting.uk.com\/kb\/how-to-add-php-code-using-a-plugin\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to add PHP code using a plugin\" \/>\n<meta property=\"og:description\" content=\"Easily add PHP code using a WordPress plugin for enhanced functionality. Explore our knowledge base for step-by-step guidance!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webhosting.uk.com\/kb\/how-to-add-php-code-using-a-plugin\/\" \/>\n<meta property=\"og:site_name\" content=\"Webhosting UK Knowledge Base\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webhostingukcom\" \/>\n<meta property=\"article:published_time\" content=\"2024-01-26T08:11:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-12-26T06:20:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_152.png\" \/>\n\t<meta property=\"og:image:width\" content=\"347\" \/>\n\t<meta property=\"og:image:height\" content=\"382\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Van\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@WebhostingUKcom\" \/>\n<meta name=\"twitter:site\" content=\"@WebhostingUKcom\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-add-php-code-using-a-plugin\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-add-php-code-using-a-plugin\\\/\"},\"author\":{\"name\":\"Van\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#\\\/schema\\\/person\\\/5c66fd2e59ccac81cc9c2d43da7272f9\"},\"headline\":\"How to add PHP code using a plugin\",\"datePublished\":\"2024-01-26T08:11:41+00:00\",\"dateModified\":\"2024-12-26T06:20:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-add-php-code-using-a-plugin\\\/\"},\"wordCount\":281,\"publisher\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-add-php-code-using-a-plugin\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/Screenshot_152-273x300.png\",\"articleSection\":[\"WordPress\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-add-php-code-using-a-plugin\\\/\",\"url\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-add-php-code-using-a-plugin\\\/\",\"name\":\"How to add PHP code using a plugin - WHUK\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-add-php-code-using-a-plugin\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-add-php-code-using-a-plugin\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/Screenshot_152-273x300.png\",\"datePublished\":\"2024-01-26T08:11:41+00:00\",\"dateModified\":\"2024-12-26T06:20:33+00:00\",\"description\":\"Easily add PHP code using a WordPress plugin for enhanced functionality. Explore our knowledge base for step-by-step guidance!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-add-php-code-using-a-plugin\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-add-php-code-using-a-plugin\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-add-php-code-using-a-plugin\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/Screenshot_152.png\",\"contentUrl\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/wp-content\\\/uploads\\\/2024\\\/01\\\/Screenshot_152.png\",\"width\":347,\"height\":382,\"caption\":\"WordPress Login\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-add-php-code-using-a-plugin\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to add PHP code using a plugin\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#website\",\"url\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/\",\"name\":\"Webhosting UK Knowledge Base\",\"description\":\"Expert Insights on Hosting, Development, Security, Marketing, and SEO\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#organization\"},\"alternateName\":\"WHUK\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#organization\",\"name\":\"Webhosting UK\",\"alternateName\":\"WHUK\",\"url\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/WHUK-logo-1.png\",\"contentUrl\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/WHUK-logo-1.png\",\"width\":1200,\"height\":628,\"caption\":\"Webhosting UK\"},\"image\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/webhostingukcom\",\"https:\\\/\\\/x.com\\\/WebhostingUKcom\",\"https:\\\/\\\/www.youtube.com\\\/c\\\/webhostinguk\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/webhosting-uk-com-ltd\\\/\",\"https:\\\/\\\/www.instagram.com\\\/webhosting_uk\\\/\",\"https:\\\/\\\/www.tiktok.com\\\/@webhostinguk\"],\"description\":\"Fast, reliable, and cost-effective website hosting services with Webhosting UK. Committed to providing you secure support around the clock.\",\"email\":\"sales@webhosting.uk.com\",\"telephone\":\"0800 862 0890\",\"legalName\":\"Webhosting UK\",\"foundingDate\":\"2001-02-07\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"51\",\"maxValue\":\"200\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#\\\/schema\\\/person\\\/5c66fd2e59ccac81cc9c2d43da7272f9\",\"name\":\"Van\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bb5079f76e01aaa97b2ffcb7a562292482693b395aba4a4214c98f006c07d352?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bb5079f76e01aaa97b2ffcb7a562292482693b395aba4a4214c98f006c07d352?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/bb5079f76e01aaa97b2ffcb7a562292482693b395aba4a4214c98f006c07d352?s=96&d=mm&r=g\",\"caption\":\"Van\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to add PHP code using a plugin - WHUK","description":"Easily add PHP code using a WordPress plugin for enhanced functionality. Explore our knowledge base for step-by-step guidance!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webhosting.uk.com\/kb\/how-to-add-php-code-using-a-plugin\/","og_locale":"en_GB","og_type":"article","og_title":"How to add PHP code using a plugin","og_description":"Easily add PHP code using a WordPress plugin for enhanced functionality. Explore our knowledge base for step-by-step guidance!","og_url":"https:\/\/www.webhosting.uk.com\/kb\/how-to-add-php-code-using-a-plugin\/","og_site_name":"Webhosting UK Knowledge Base","article_publisher":"https:\/\/www.facebook.com\/webhostingukcom","article_published_time":"2024-01-26T08:11:41+00:00","article_modified_time":"2024-12-26T06:20:33+00:00","og_image":[{"width":347,"height":382,"url":"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_152.png","type":"image\/png"}],"author":"Van","twitter_card":"summary_large_image","twitter_creator":"@WebhostingUKcom","twitter_site":"@WebhostingUKcom","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-add-php-code-using-a-plugin\/#article","isPartOf":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-add-php-code-using-a-plugin\/"},"author":{"name":"Van","@id":"https:\/\/www.webhosting.uk.com\/kb\/#\/schema\/person\/5c66fd2e59ccac81cc9c2d43da7272f9"},"headline":"How to add PHP code using a plugin","datePublished":"2024-01-26T08:11:41+00:00","dateModified":"2024-12-26T06:20:33+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-add-php-code-using-a-plugin\/"},"wordCount":281,"publisher":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/#organization"},"image":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-add-php-code-using-a-plugin\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_152-273x300.png","articleSection":["WordPress"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-add-php-code-using-a-plugin\/","url":"https:\/\/www.webhosting.uk.com\/kb\/how-to-add-php-code-using-a-plugin\/","name":"How to add PHP code using a plugin - WHUK","isPartOf":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-add-php-code-using-a-plugin\/#primaryimage"},"image":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-add-php-code-using-a-plugin\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_152-273x300.png","datePublished":"2024-01-26T08:11:41+00:00","dateModified":"2024-12-26T06:20:33+00:00","description":"Easily add PHP code using a WordPress plugin for enhanced functionality. Explore our knowledge base for step-by-step guidance!","breadcrumb":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-add-php-code-using-a-plugin\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webhosting.uk.com\/kb\/how-to-add-php-code-using-a-plugin\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-add-php-code-using-a-plugin\/#primaryimage","url":"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_152.png","contentUrl":"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2024\/01\/Screenshot_152.png","width":347,"height":382,"caption":"WordPress Login"},{"@type":"BreadcrumbList","@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-add-php-code-using-a-plugin\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webhosting.uk.com\/kb\/"},{"@type":"ListItem","position":2,"name":"How to add PHP code using a plugin"}]},{"@type":"WebSite","@id":"https:\/\/www.webhosting.uk.com\/kb\/#website","url":"https:\/\/www.webhosting.uk.com\/kb\/","name":"Webhosting UK Knowledge Base","description":"Expert Insights on Hosting, Development, Security, Marketing, and SEO","publisher":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/#organization"},"alternateName":"WHUK","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webhosting.uk.com\/kb\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/www.webhosting.uk.com\/kb\/#organization","name":"Webhosting UK","alternateName":"WHUK","url":"https:\/\/www.webhosting.uk.com\/kb\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.webhosting.uk.com\/kb\/#\/schema\/logo\/image\/","url":"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2023\/08\/WHUK-logo-1.png","contentUrl":"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2023\/08\/WHUK-logo-1.png","width":1200,"height":628,"caption":"Webhosting UK"},"image":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webhostingukcom","https:\/\/x.com\/WebhostingUKcom","https:\/\/www.youtube.com\/c\/webhostinguk","https:\/\/www.linkedin.com\/company\/webhosting-uk-com-ltd\/","https:\/\/www.instagram.com\/webhosting_uk\/","https:\/\/www.tiktok.com\/@webhostinguk"],"description":"Fast, reliable, and cost-effective website hosting services with Webhosting UK. Committed to providing you secure support around the clock.","email":"sales@webhosting.uk.com","telephone":"0800 862 0890","legalName":"Webhosting UK","foundingDate":"2001-02-07","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"51","maxValue":"200"}},{"@type":"Person","@id":"https:\/\/www.webhosting.uk.com\/kb\/#\/schema\/person\/5c66fd2e59ccac81cc9c2d43da7272f9","name":"Van","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/bb5079f76e01aaa97b2ffcb7a562292482693b395aba4a4214c98f006c07d352?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/bb5079f76e01aaa97b2ffcb7a562292482693b395aba4a4214c98f006c07d352?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/bb5079f76e01aaa97b2ffcb7a562292482693b395aba4a4214c98f006c07d352?s=96&d=mm&r=g","caption":"Van"}}]}},"_links":{"self":[{"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/posts\/16462","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/comments?post=16462"}],"version-history":[{"count":6,"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/posts\/16462\/revisions"}],"predecessor-version":[{"id":19141,"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/posts\/16462\/revisions\/19141"}],"wp:attachment":[{"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/media?parent=16462"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/categories?post=16462"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/tags?post=16462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}