the_meta WORKS, get_post_meta does not
-
Extensive searching and tweaking failed to make this work. I’m trying to pull one custom field value into a post (the same post that has the custom field).
CANNOT get any variant of get_post_meta to work. If I use the_meta(), the field shows, but so do all the fields as expected.
PHP is executable in my post via a plugin (and I have other PHP statements working fine in the test post).
I’ve probably tried twenty ways to do this, include these approaches (not all together, one at a time):
<?php $key="cost"; echo get_post_meta($post->ID, $key, true); ?> <?php $key="cost"; print get_post_meta($post->ID, $key, true); ?> <?php $cost = get_post_meta($post->ID, 'price', true); ?> <?php print($cost) ?> <?php $cost = get_post_meta($post->ID, 'price', false); ?> <?php echo ($cost) ?>
…and every combination of true/false, print/echo, $value = true, true, etc. etc.
I’ve seen a few posts where folks running the same version (2.8.4) are claiming get_post_meta quit working when they upgraded. Is there an issue with this version, or have I just not found the magic version #21? ??
Thx.,
Gary
- The topic ‘the_meta WORKS, get_post_meta does not’ is closed to new replies.