• Resolved Holkan

    (@cubeinthebox)


    Hello.

    I’m trying to get some post_metas in AMP pages, but the thing is that it seems like some of the post_meta isn’t getting to AMP.

    When I get all the metadata associated to the post with get_metadata('post', get_the_id()); I can see all the post meta keys and values associated with that post object, for some reason not all the post_metas are listed in the metadata object. I have two post_metas missing and I don’t know why only those two are lose since almost the rest of post metas in the metadata object are also custom post_meta (metaboxes) and they are made with the same logic.

    Please any advice is welcome

    Here is the line: $metadata = get_metadata('post', get_the_id());

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Weston Ruter

    (@westonruter)

    What happens if you use get_queried_object_id() instead of get_the_id()?

    Thread Starter Holkan

    (@cubeinthebox)

    Sorry for the late reply.
    That same day I realized that if I want to access data from within your plugin I had to get in context. After a little digging in the code I found that the way to access the post ID and other data is through something like this: get_post_meta($this->get( 'post_id' ), 'post_meta', true);

    Thanks for take the time to answer my naive question!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Can’t get post meta in amp pages’ is closed to new replies.