Title: Adding Custom Fields
Last modified: August 18, 2016

---

# Adding Custom Fields

 *  Anonymous
 * [22 years, 1 month ago](https://wordpress.org/support/topic/adding-custom-fields/)
 * How do you add a Custom Field field into your template? What is the code you 
   use?
    Thanks 🙂

Viewing 12 replies - 1 through 12 (of 12 total)

 *  [lilandra](https://wordpress.org/support/users/lilandra/)
 * (@lilandra)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/adding-custom-fields/#post-49363)
 * what *is* a custom field for?
 *  [rpeeck](https://wordpress.org/support/users/rpeeck/)
 * (@rpeeck)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/adding-custom-fields/#post-49365)
 * ^^ lol… i was wondering about that too…
 *  [lilandra](https://wordpress.org/support/users/lilandra/)
 * (@lilandra)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/adding-custom-fields/#post-49366)
 * maybe it’s like you can define a field called mood or music or breakfast?
    and
   use those instead of the hacks? hmmmm must experiment, in June and i’mglad it’s
   not just me!
 *  [Sushubh](https://wordpress.org/support/users/sushubh/)
 * (@sushubh)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/adding-custom-fields/#post-49371)
 * [http://wiki.wordpress.org/index.php/PostMeta](http://wiki.wordpress.org/index.php/PostMeta)
 *  [lilandra](https://wordpress.org/support/users/lilandra/)
 * (@lilandra)
 * [22 years, 1 month ago](https://wordpress.org/support/topic/adding-custom-fields/#post-49374)
 * thank you
 *  [lonney](https://wordpress.org/support/users/lonney/)
 * (@lonney)
 * [21 years, 8 months ago](https://wordpress.org/support/topic/adding-custom-fields/#post-50261)
 * Hi, I’m still a bit lost with this, I’m thinking about switching to WP for my
   blog.
    I’m travelling at the moment, and I want to have a location (county & 
   place ) entry, that defaults to the last location posted from. I’m lost as to
   how to make this field, (the information isnt very clear on how to do this) add
   it to the write page, and to the template. Also in the template have it build
   a list of menu/links so for example someone can view all the posts I made from
   England and or more specific London. Any pointers to info on how best to do this
   would be great 🙂 Lonney
 *  [nubeli](https://wordpress.org/support/users/nubeli/)
 * (@nubeli)
 * [21 years, 7 months ago](https://wordpress.org/support/topic/adding-custom-fields/#post-50267)
 * I’m not sure how you can get it to default to the last location. But it is pretty
   easy to create a key called “Location” and then to add a key/value to each post.
   For example, a new post allows you to choose a set key (like “Location”) and 
   then put a value (“Istanbul”). Or you can add a new key like “Fruit” and value“
   Apple”.
    Then to get it to appear in the post, the most basic way is to use the_meta
   tag: `?php the_meta(); ?>` within The Loop. The Loop is everything in your index.
   php (or other template file) between: `<?php if ($posts) { foreach ($posts as
   $post) { start_wp(); ?>` and `<?php } } else { ?>`
 *  [nubeli](https://wordpress.org/support/users/nubeli/)
 * (@nubeli)
 * [21 years, 7 months ago](https://wordpress.org/support/topic/adding-custom-fields/#post-50268)
 * Lonney, it is probably a lot easier if you just use Categories to create your
   menu links. Since you can create hierarchical categories you could have England
   >London, Bath, …. and it would all appear in the menu.
    It’s possible to create
   menu links using the custom fields, but not simple. Although you could fiddle
   around with the [get_custom plugin](http://www.coffee2code.com/archives/2004/06/30/plugin-get-custom/).
   I haven’t tried it.
 *  [gaebe](https://wordpress.org/support/users/gaebe/)
 * (@gaebe)
 * [21 years, 6 months ago](https://wordpress.org/support/topic/adding-custom-fields/#post-50276)
 * I still don’t get it very well. I want to create a custom field “current mood”
   for all of my entries. How do I make the field automatically appear in the write
   page (post.php) so that I can directly enter the values?
 *  [gaebe](https://wordpress.org/support/users/gaebe/)
 * (@gaebe)
 * [21 years, 6 months ago](https://wordpress.org/support/topic/adding-custom-fields/#post-50277)
 * And can someone tell me how to edit the appearance of the field on the blog?
 *  [serendipity](https://wordpress.org/support/users/serendipity/)
 * (@serendipity)
 * [21 years, 6 months ago](https://wordpress.org/support/topic/adding-custom-fields/#post-50278)
 * OK, the first request requires a bit of editing in edit-form/edif-form-advanced.
   php (to create a form field to enter the custom field) plus post.php . For example(
   untested!! I just copied some edits I made that work for me):
    In edit-form-advanced.
   php — ` <fieldset class="mooddiv"> <legend><?php _e('Mood') ?></legend> <div>
   <input type="text" name="my_mood" size="3" tabindex="2" id="my_mood" /></div>
   </fieldset>  + adjust tabindex, css for .mooddiv. In post.php / editpost section—
   if(isset($_POST['my_mood'])) { $_POST['metakeyselect'] = 'my_mood'; $_POST['metavalue']
   = $_POST['my_mood']; add_meta($post_ID); }  For the second, I’d recommend using
   coffee3code’s [get custom field values plugin](http://www.coffee2code.com/archives/2004/06/30/plugin-get-custom/).
 *  [amory](https://wordpress.org/support/users/amory/)
 * (@amory)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/adding-custom-fields/#post-50302)
 * serendipity where does the second part go in post.php?

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Adding Custom Fields’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 12 replies
 * 9 participants
 * Last reply from: [amory](https://wordpress.org/support/users/amory/)
 * Last activity: [21 years, 1 month ago](https://wordpress.org/support/topic/adding-custom-fields/#post-50302)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
