wordpress adding post custom field meta and displaying it on you template

if you want to be able to add custom post fields into your pages in wordpress and display them in your template this is how you can do it, no plugin is required for this as post meta is available by default in wordpress

in wordpress enable custom fields in options / advanced options

Then add a new custom field to the page and save it. 

You can then retrieve this field with the following code on your template.


$custom_field_text = get_post_meta( $id, 'Custom Field Name', true );
if(!($custom_field_text > "")) { $custom_field_text= "Default Value"; }

Search Code
Search Code by entering your search text above.

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.


Random Quote
All of humanity's problems stem from man's inability to sit quietly in a room alone, wrote Blaise Pascal.