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

I have some custom fields added via a meta box, and I'd like to output them into a dl on the post itself, with the field being the term and the data it contains being the term. Currently, calling <?php the_meta(); ?> outputs an unordered list.


  <dt>Date</dt><dd>Monday 26 March 2012</dd>

I have the meta box fully implemented, it's just the output that I'm clueless with. The relevant part of the meta box code, should it help:

function admin_init(){
  add_meta_box("events_meta", "Event Details", "event_details", "post", "normal", "default");

function event_details() {
  global $post;
  $custom = get_post_custom($post->ID);
  $date = $custom["date"][0];
  $time = $custom["time"][0];
  $location = $custom["location"][0];
  $tickets = $custom["tickets"][0];
  <p><label>Date:</label><br />
  <textarea cols="34" rows="2" name="date"><?php echo $date; ?></textarea></p>
  <p><label>Time:</label><br />
  <textarea cols="34" rows="2" name="time"><?php echo $time; ?></textarea></p>
  <p><label>Location:</label><br />
  <textarea cols="34" rows="2" name="location"><?php echo $location; ?></textarea></p>
  <p><label>Ticket Price(s):</label><br />
  <textarea cols="34" rows="2" name="tickets"><?php echo $tickets; ?></textarea></p>

Thanks in advance for any help! :)

share|improve this question
up vote 0 down vote accepted

You can use get_post_meta() function to retrieve values of fields.

Example :

To retrieve the value of date metabox use following code.

get_post_meta(get_the_ID(), 'date', true);
share|improve this answer
That worked perfectly in conjunction with an echo <?php if ( get_post_meta($post->ID, 'date', true) ) : ?> <dt id="date-icon">Date</dt> <dd><?php echo get_post_meta($post->ID, 'date', true) ?></dd> <?php endif; ?> Thanks! :) – TheGuest Mar 27 '12 at 13:49

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.