If a custom field exists for a post, output the value
-
I’m moving to WordPress from a custom CMS. We used to give articles/posts an image that was then displayed on our home page.
Well, this isn’t supported by WP by default, but that’s cool because I plan on using a custom field to do this. I’ll name the custom field ‘image’ if there is an image available for a particular post.
So, I create a custom field ‘image’ with the value ‘test.jpg’
In the loop, I’ve got:
<?php if (get_post_meta ($post->ID, "image", $single = true)) { ?><img src="<?php get_post_meta($post->ID, $key, $single = true); ?>" /><?php } ?>
It doesn’t seem to work ?? and I’m not to sure where to go from here.
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘If a custom field exists for a post, output the value’ is closed to new replies.