All the content added in the “Custom AMP editor” 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’re passing 3 parameter
If you want to know more about get post meta then you can check this official documentation
https://developer.wordpress.org/reference/functions/get_post_meta/
Syntax:
get_post_meta( int $post_id, string $key = '', bool $single = false )
get_post_meta(ampforwp_get_the_ID,’ampforwp_custom_content_editor’, true ) ;
Parameters:
- get_the_ID: By using this parameter you can retrieve the ID of the current item in the WordPress Loop
- ampforwp_custom_content_editor: By using this key you can fetch the data saved in Custom AMP Content
- true: By default this value is false
This is the example of Code
$data = get_post_meta(ampforwp_get_the_ID,'ampforwp_custom_content_editor', true ); if($data){ echo $data; }
That’s it for this tutorial!
We hope it helped you. If you have any feedback or questions, then please share them in the comments section below..
i need amp custom editor for website on php
Hi Rajat,
If you want to add PHP in the AMP version then you can just create a new file or even you can write in your functions.php of your theme and in that you need to use our hooks and filters, for example, we have a hook called “pre_amp_render_post” you can use this hook and add code that will only appear in amp. we already have a lot of hooks here – https://ampforwp.com/tutorials/article/hooks-in-ampforwp/ you can use it according to you