get_post_meta in amp?
-
Hi, I’m trying to implement custom post meta data to display in the single.php AMP template.
I’m however unable to show the data from the wordpress function get_post_meta($post->ID, ‘post-meta’, true) – how do you implement that in AMP?
Here’s a test for a youtube video:
The post meta data is filled out with: O7OqaMkymWI
My code is
<script async custom-element="amp-youtube" src="https://cdn.ampproject.org/v0/amp-youtube-0.1.js"></script> <?php $src = get_post_meta($post->ID, 'meta-data', true); echo '<amp-youtube layout="responsive" data-videoid="'. $src.'" width="480" height="270" allowfullscreen></amp-youtube>'; ?>
Intented result:
<amp-youtube layout="responsive" data-videoid="O7OqaMkymWI" width="480" height="270" allowfullscreen></amp-youtube>
The error is
Uncaught (in promise) Error: failed to build: amp-youtube#3: Exactly one of data-videoid or data-live-channelid should be present for <amp-youtube> amp-youtube
Thanks for the help!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘get_post_meta in amp?’ is closed to new replies.