{"id":11368,"date":"2019-06-20T11:08:06","date_gmt":"2019-06-20T11:08:06","guid":{"rendered":"https:\/\/ampforwp.com\/tutorials\/?post_type=ht_kb&#038;p=11368"},"modified":"2020-05-07T12:04:58","modified_gmt":"2020-05-07T12:04:58","slug":"how-to-create-a-custom-plugin-on-top-of-amp-for-wp","status":"publish","type":"ht_kb","link":"https:\/\/ampforwp.com\/tutorials\/article\/how-to-create-a-custom-plugin-on-top-of-amp-for-wp\/","title":{"rendered":"How to create a custom plugin on top of AMP for WP"},"content":{"rendered":"\n<p>If you do any changes or modifications in our core AMPforWP plugin then once you update our plugin then all your custom changes which you have made will be removed and its highly not recommended to create custom changes in the core plugin but if you want to make it as update proof then you need to follow these steps.<\/p>\n\n\n\n<p> <strong>Step 1:<\/strong>  To create a custom plugin, create a folder and then create a single file with one line of content. Navigate to the wp-content\/plugin folder, and create a new folder named &#8220;<strong>ampcustomplugin<\/strong>&#8220;. Inside this new folder, create a file named &#8220;<strong>ampcustomplugin.php<\/strong>&#8220;. Open the file in a text editor, and paste the following information in it. <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text\/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;PHP&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;php&quot;}\">\/*\n\nPlugin Name: AMP Custom Plugin\n\nPlugin URI: https:\/\/wordpress.org\/plugins\/accelerated-mobile-pages\/\n\nDescription: a plugin to create ampcustomplugin and spread joy\n\nVersion: 1.0\n\nAuthor:  Mohammed Kaludi\n\nAuthor URI: http:\/\/ampforwp.com\/ \n\nLicense: GPL2\n\n*\/<\/pre><\/div>\n\n\n\n<p><strong>Step 2:<\/strong> Once you save this file Custom plugin will be created on <strong>WordPress dashboard<\/strong> -&gt;<strong> plugin page<\/strong> now click &#8220;<strong>Activate<\/strong>&#8221; link like below the screenshot.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"208\" src=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/06\/activate-link-1-1024x208.png\" alt=\"\" class=\"wp-image-11390\" srcset=\"https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/06\/activate-link-1-1024x208.png 1024w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/06\/activate-link-1-300x61.png 300w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/06\/activate-link-1-768x156.png 768w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/06\/activate-link-1-50x10.png 50w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/06\/activate-link-1-60x12.png 60w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/06\/activate-link-1-100x20.png 100w, https:\/\/ampforwp.com\/tutorials\/wp-content\/uploads\/2019\/06\/activate-link-1.png 1263w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><strong>Step 3: <\/strong>Open that file and with the help of our filter and hooks you can modify almost everything which you need and to get the complete list of all our hooks\/filters <a href=\"https:\/\/ampforwp.com\/tutorials\/article\/hooks-in-ampforwp\/\">Click Here<\/a><\/p>\n\n\n\n<p><strong>Case 1: <\/strong>If you want to add banner in the below of the content then follow this <a href=\"https:\/\/ampforwp.com\/tutorials\/article\/extend-amp-plugin\/\">article<\/a>.<\/p>\n\n\n\n<p><strong>That\u2019s it for this tutorial!<\/strong><\/p>\n\n\n\n<p>We hope it helped you. If you have any feedback or questions, then please share them in the comments section below.<\/p>\n<div id=\"div-1\" class=\"hkb-feedback\">\n\t\t\t<strong class=\"ht-mobile-exit__title\">Ask your Questions Directly!<\/strong><br>\n\t\t\t<div class=\"hkb_widget_exit__content\" style=\"font-size: 14px;\">If you can't find the solutions in this article, then just ask us in the comments and we will answer it for you!<\/div>\n\t\t\t<a href=\"https:\/\/ampforwp.com\/support\/#contact\" id=\"button\" target=\"_blank\" rel=\"noopener noreferrer\"><button>Yes, I have a Question<\/button><\/a>\n\t\t<\/div>","protected":false},"excerpt":{"rendered":"<p>If you do any changes or modifications in our core AMPforWP plugin then once you update our plugin then all your custom changes which you have made will be removed and its highly not recommended to create custom changes in the core plugin but if you want to make it&#8230;<\/p>\n","protected":false},"author":18,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":[],"ht-kb-category":[34],"ht-kb-tag":[],"_links":{"self":[{"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb\/11368"}],"collection":[{"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/comments?post=11368"}],"version-history":[{"count":31,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb\/11368\/revisions"}],"predecessor-version":[{"id":17283,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb\/11368\/revisions\/17283"}],"wp:attachment":[{"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/media?parent=11368"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb-category?post=11368"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb-tag?post=11368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}