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.

What is the best way to display/dump all custom fields associated with a post? It doesn't have to be pretty, I just need to verify what is being saved in what field array for debugging.

Thanks!

share|improve this question

2 Answers 2

up vote 2 down vote accepted

you can use get_post_custom() which returns a multidimensional array with all custom fields of a particular post or page:

echo '<pre>';
print_r(get_post_custom($post_id));
echo '</pre>';
share|improve this answer
    
That worked great, thank you! –  mattrepublic May 26 '11 at 14:08
    
I'm using this function to print the array, how can I specify only two custom fields to print their key and value? custom1, and custom2 –  Anagio Dec 22 '12 at 9:24
    
@Anagio take a look at this codex.wordpress.org/Function_Reference/get_post_meta –  Bainternet Dec 22 '12 at 13:24

get_post_custom($post->ID) is what you need

share|improve this answer

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.