Support » Fixing WordPress » the_meta WORKS, get_post_meta does not

Viewing 7 replies - 1 through 7 (of 7 total)
  • If you echo $post->ID; do you get a valid value?

    No, get nothing.

    esmi

    (@esmi)

    Forum Moderator

    Then that’s your problem. get_post_meta() can’t do anything without a valid id.

    Thanks for the direction tip. This code:

    <?php echo get_post_meta(get_the_ID(), "Price", true); ?>

    …finally did the trick.

    Joel

    (@jneuenhaus)

    Dope… many thanks for this.

    Mental note:
    get_the_ID is a function which retrieves the ID of the current item in the WordPress Loop, providing access to meta data for each post in the loops array.

    eivindvr

    (@eivindvr)

    nice work:-D

    I have this problem but in my code I have the ID, it just doesn’t work for some fields. I use Magic Fields plugin for attaching custom fields to posts.

    It prints the number type fields, but not the text ones. Did any of you got this bug?

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘the_meta WORKS, get_post_meta does not’ is closed to new replies.