Adding external field to my post form (admin side) and to post show (frontend side)

(Just read the third link in your question. It looks like a line of code is missing on step #4. I don’t think there’s really a need to use the plugin.)

There are two ways to do what you are requesting. 1) Learn what a metabox is, or 2) become acquainted with the custom fields box on the edit-post screen in the WordPress admin. Both methods use the same database table to store their information which is relative to a post.

If you are just starting out and this is for you (and not a client), I’d recommend method 2 – the custom field box on the edit-post screen (you may need to toggle its visibility from the “screen options” drop down menu near the top right corner of the screen).

Once it is visible, you’ll need to create a name => value pair. In your case, give it a name of “source” and then type in the value as whatever that source should be. Remember the name that you use in the name field, as you’ll want to make sure that it is the same name for every post entry (in this case “source”). Once you’ve created it the first time, it should also become available as a drop down option on subsequent post entries.

By doing this, what you are creating is a postmeta entry in the database which has just four columns (or settings): a unique ID, the post ID, the name, and the value (which you should have just created). I point this out, only because metaboxes (option 1 from above) creates the exact same entry in the database.

Now, to access this information from within your template, you need only use the get_post_meta($post_id, $meta_name); function to get your source information. Something like this should work from inside the WordPress loop:

$source_value = get_post_meta($post_id, 'source');
if( isset( $source_value ) ){
    echo $source_value;
}

This is the custom fields way of doing it.


On the other hand, if you want to create a cleaner presentation on your edit-post screen that will also have the name set for you, that’s where you’d learn how to use a metabox.

If you want to experiment with metaboxes, you can either learn it straight by reading the WordPress Codex on metaboxes (how to add, edit, etc.) or use a metabox class or plugin. I’ve used Dimas’s WP Alchemy Class and also RW MetaBox Class. Justin Taddock has a good tutorial on how to work straight with the built-in functions to create a metabox.

With any of these metabox approaches the way to retrieve information for use in your theme is essentially the same. Just pay attention to your meta_name value.

How’s this for a starting point?