{"id":10836,"date":"2019-06-07T12:37:40","date_gmt":"2019-06-07T12:37:40","guid":{"rendered":"https:\/\/ampforwp.com\/tutorials\/?post_type=ht_kb&#038;p=10836"},"modified":"2020-05-07T05:56:14","modified_gmt":"2020-05-07T05:56:14","slug":"displaying-custom-amp-editor-content-through-php-code","status":"publish","type":"ht_kb","link":"https:\/\/ampforwp.com\/tutorials\/article\/displaying-custom-amp-editor-content-through-php-code\/","title":{"rendered":"Displaying \u201cCustom AMP editor\u201d Content through php code"},"content":{"rendered":"\n<p>All the content added in the &#8220;<strong>Custom AMP editor<\/strong>&#8221; will be saved in post meta. <br><\/p>\n\n\n\n<p>If you want to fetch the data from Custom AMP editor then use below the function  <\/p>\n\n\n\n<p><strong>get_post_meta()<\/strong> is a function and in that we&#8217;re passing 3 parameter <\/p>\n\n\n\n<p>If you want to know more about get post meta then you can check this official documentation<\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_post_meta\/\" target=\"_blank\">https:\/\/developer.wordpress.org\/reference\/functions\/get_post_meta\/<\/a><\/p>\n\n\n\n<h4>Syntax:<\/h4>\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;}\"> get_post_meta( int $post_id, string $key = '', bool $single = false ) <\/pre><\/div>\n\n\n\n<p><strong>get_post_meta(ampforwp_get_the_ID,&#8217;ampforwp_custom_content_editor&#8217;, true ) ;  <\/strong><\/p>\n\n\n\n<h4 id=\"parameters\">Parameters: <\/h4>\n\n\n\n<ul><li><strong>get_the_ID:<\/strong> By using this parameter you can retrieve the ID of the current item in the WordPress Loop<\/li><\/ul>\n\n\n\n<ul><li> <strong>ampforwp_custom_content_editor<\/strong>: By using this key you can fetch the data saved in Custom AMP Content <\/li><\/ul>\n\n\n\n<ul><li><strong> true: <\/strong>By default this value is false<\/li><\/ul>\n\n\n\n<p><strong>This is the example of Code<\/strong><br><\/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;}\"><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;}\" class=\"brush: php; title: ; notranslate\" title=\"\"> $data = get_post_meta(ampforwp_get_the_ID,'ampforwp_custom_content_editor', true );\nif($data){\necho $data;\n}<\/pre><\/pre><\/div>\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..<br> <br><br> <\/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>All the content added in the &#8220;Custom AMP editor&#8221; will be saved in post meta. If you want to fetch the data from Custom AMP editor then use below the function get_post_meta() is a function and in that we&#8217;re passing 3 parameter If you want to know more about get&#8230;<\/p>\n","protected":false},"author":18,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":[],"ht-kb-category":[183],"ht-kb-tag":[],"_links":{"self":[{"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb\/10836"}],"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=10836"}],"version-history":[{"count":52,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb\/10836\/revisions"}],"predecessor-version":[{"id":17249,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb\/10836\/revisions\/17249"}],"wp:attachment":[{"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/media?parent=10836"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb-category?post=10836"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/ampforwp.com\/tutorials\/wp-json\/wp\/v2\/ht-kb-tag?post=10836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}