I did these tree tutorials to create custom metaboxes.
- wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-1-intro-and-basic-fields/
- wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-2-advanced-fields/
- wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-3-extra-fields/
but i don’t know how to call values from individual fields. I used this php script
$meta = get_post_meta($post->ID, $field['id'], true);
echo $meta;
but id doesn’t work. Does someone know what I do wrong.
here is my function.php
http://www.4shared.com/file/8jmKqGFY/functions.html?
and here is my index.php
http://www.4shared.com/file/iAWwZim7/index.html?
After reviewing your code there are a couple of things you need to change depending on where the meta content is being held.
If you try
That should give you the appropriate meta.
You are calling this function on the page content, so unless the meta content is being held there nothing will be output.
Hope that helps!
If you’re not on a template file where you can’t use
get_the_ID()
(say you’re on a plugin file), first get a pointer to the post object associated with the meta content and then use$post->ID
.For example, if you used
add_meta_box
to define a function displaying the meta box (saydisplay_meta_box
), you can retrieve the meta box value thus: