WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How i can add custom fields to custom post templates, and later print them in The Loop?

Better explanation: I want to have a custom field in "Add New" window, which will be added as some meta data to the post, which can be later printed in the loop of single.php.

I want to be able to decide where it will be, so it can be even under comments if i want to (i want to define it in template).

I dont want "Custom Field Template" plugin because AFAIK this cannot be used inside the loop.

share|improve this question

You can call get_post_custom() in The Loop, to retrieve an array with all custom fields for a post. In order to fetch a single field, you can use get_post_meta($post_id, $key, $single) with the third argument set to TRUE.

share|improve this answer
How to add those custom meta data to post? – Riki137 Dec 8 '11 at 16:28

Your Answer


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.