Get Custom Fields | Very Versatile WordPress Plugin

The Get Custom Fields plugin is an extremely versatile WordPress Plugin. It's really like having dozens and dozens of plugins rolled into one, once you get used to the idea behind it.

To make this work you assign values to custom fields in the 'custom fields' entry on your post form. Then, with a simple call to the c2c_get_custom_fields(); plugin function, you can display these little bits of custom data in your blog. You can display them either in the loop or outside it.

The first step is to add a custom field key/value pair. At the bottom of your post entry form you'll see this.

WordPress custom fields post form

Now lets say we want to include a certain type of data with every post, but we don't want to display it in the post. For instance with a picture blog we might want to include the camera we used.

So we could create a key named 'camera' and in one post give it the value of 'nikon esf1000' and in another post we could give it a value of 'Kodak OL125' (These are fictional cameras and I doubt they exist). Now in the template for the blog single post we can create a div for picture details and call the c2c_get_custom_fields(); function to display the camera used for each shot. This could be a div that is floated at the top of the post, or it could even be listed in the sidebar. We cold also include custom fields for the light readings, location, film, shutter speed, and whatever else a photographer might be interested in.

Any fields we call with this plugin, that we do not define in the post custom fields entry, will simply display nothing, unless you include a special "none" text with the function.

Another use for this plugin would be to use it as a conditional operator. Lets say we want to do some interviews in some of our posts, and we want to include a special section on those posts detailing some information about the person we are interviewing. We could include a key called 'interview' and give it a value of 'yes' on interview blogs. Ten we can simply use an if(); function to see if the interview key has a value of yes. If it does we can include the special biography section of code, which could use custom fields defined about the interview subjects, or if not, skip the whole section.

You can visit the Get Custom Fields plugin page, for exact instructions on how to implement it in your templates, and I will be posting some examples soon.

Right now if you visit one of the tag pages on this blog, the description of each post is actually being pulled from a custom field I set up called 'oneliner'. It just has a short one sentence description of the post, so that I can display that on my tag pages, and save my excerpts for my category pages, which are more frequently visited in any case.

Trackback URL for this post:

http://danemorgan.com/trackback/21
None
Login or register to tag items
 
Posted In
Tagged With
Like this?
Bookmark & Share:
StumbleUpon Submit to Mixx Save to Google Bookmarks Save to del.icio.us
Click, Copy and Link:
<a href="http://danemorgan.com/blog/wordpress/get-custom-fields-124-very-versatile-wordpress-plugin">Get Custom Fields &#124; Very Versatile WordPress Plugin</a>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • Restrict text by wrapping in [restrict:roles=<comma separated roles>] and [/restrict]
  • Links to specified hosts will have a rel="nofollow" added to them.

  • Highlight terms in this textarea.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]".
  • Use <fn>...</fn> to insert automatically numbered footnotes.
  • You may link to webpages through the weblinks registry

More information about formatting options

CAPTCHA
Please fill out this captcha to demonstrate your humanity.
3 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.