Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
replace $field['id'] with the actual id you gave the field –  Bainternet Mar 2 '12 at 10:06
    
I did this, but it display nothing –  Itachi Mar 2 '12 at 10:12
1  
Can you show us your full loop code? –  Alex Older Mar 2 '12 at 10:56
    
here is my functions.php 4shared.com/file/8jmKqGFY/functions.html? and here is my index.php 4shared.com/file/iAWwZim7/index.html? –  Itachi Mar 4 '12 at 15:08
1  
Are you sure you have the correct meta key? Maybe try print_r( get_post_custom_keys($post_id) ); and you will see all the meta keys associated with that post. (Also for code sharing, I would suggest something like Pastie) –  Cristian Mar 7 '12 at 8:59
show 1 more comment

1 Answer

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

$meta = get_post_meta( get_the_ID(), 'custom_text', TRUE );
echo 'The meta content is: ' . $meta;`

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!

share|improve this answer
    
no it doesn't work but I figured it out :) Solution is this $meta = get_post_meta($post->ID, $field['custom_text'], true); echo $meta[custom_text][0]; Thx for your help –  Itachi Mar 10 '12 at 21:05
1  
Don't for to accept the answer so in the future people know how to get to the solution you did. Also it's polite. –  Joshua May 21 '12 at 2:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.