Trouble with Custom Fields/ get_post_meta_data
-
Hi all. I’m trying to use some custom fields for content I display frequently in my posts. For example, I made a key ‘image_url’ and have tried to call it in my posts to no avail.
As far as I know, this should work:
<?php $image_url = get_post_meta($post->ID, 'image_url', true); ?> <?php echo($image_url); ?>
I’ve also tried these:
<?php echo get_post_meta($post->ID, 'image_url', true); ?>
<?php $image_url="image_url"; echo get_post_meta($post->ID, 'image_url', true); ?>
However, WordPress successfully lists all my custom fields with the_meta so I’m not sure why I can’t display individual custom fields how I want to. None of those displays anything at all.
Is there some simple syntax error? Is there some bug in get_post_meta? Do I need to edit my functions.php, maybe?
- The topic ‘Trouble with Custom Fields/ get_post_meta_data’ is closed to new replies.