Custom fields in Wordpress

100507

In my spare time I’ve been working on the second incarnation of deanjrobinson.com and I planning on making it more than a fresh skin over the same underbelly. First time around I was trying to build my site AND make the theme ‘releaseable’ at the same time, which meant I didn’t want to mess with the way certain things worked (yes, I know there were still some “weird” things that got through).

This time I’m building just for me, so I’ve been thinkin of new ways to go about some things, and to better use some of the functionality that Wordpress provides. One such feature is the custom fields that you can attach to posts and pages. Currently I use a few plugins that make use of them such as post ratings and post views, but I’m looking at using them more in ways that will speed up my posting and make updating certain content items much simpler. This is what I’ve got in mind.

I’m using the wordpress download manager plugin to track my downloads, and at the moment I have to add the download link, counter etc using there supplied quicktags whenever I include a download in a post. What I’m planning to do (and I already have this working in my local test) is to build the download ‘block’ into my templates, and just store the id of the download in a custom field.

So if a page has a download ‘associated’ with it the block will be displayed, if theres no download, theres no block, simple as that. This removes the need for me to remember the little block of code that I’ve been using to display the download links, and all I need to put in is the id of the download. I think its pretty neat.

An early example of what the output of the download ‘block’ might look like.

New style preview

So that was the first thing I thought of and tried, then I got to thinking what else I could use these custom fields for. So far these are a few of the other ideas that could potentially be very useful to me.

  • Storing the link to a support thread/topic for relevant posts
  • Storing the link to the related ‘project’ page for things like Redoable and Twitt-Twoo
  • Storing the link for the external url for my sidenotes

Not only will these changes make things a little quicker and simpler in the long run, they will also give me a little more flexibility in how I display the content of my posts and pages.

Does anyone else using these custom fields in strange/interesting/useful ways, if you do, it would be great to see what you’ve done.

10 Responses to “Custom fields in Wordpress”

  1. Jim
    Jim

    Far as I know custom fields are just meta that don’t get displayed by default. To display content inside custom fields you need something like the get custom fields plugin:
    http://www.coffee2code.com/archives/2004/06/30/plugin-get-custom/

  2. dean.j.robinson
    dean.j.robinson

    It can be done without the need for any extra plugins, personally I feel that the default Wordpress methods for making use of the meta data are more than enough, and the plugin you’ve mentioned is a little bit of overkill for my needs.

    It could be possible that the plugin was around before the functionality was available as part of the Wordpress core.

    If you’re interested this is the link to details about custom/meta fields from the Wordpress codex:
    http://codex.wordpress.org/Using_Custom_Fields

  3. Jim
    Jim

    Ahh, right you are. I’ve used the plugin in the past just because the functionality wasn’t already baked in. I see that it is now, which is great.

  4. bfnh
    bfnh

    i didn’t like the way wordpress handled the “more” link so i use a custom field to store the text that i want displayed. if it exists, it is displayed & if not, it reverts to the default.

  5. Evan
    Evan

    Have you taken a look at this plugin?

    http://www.cimatti.it/blog/2007/02/12/cimy-user-extra-fields-for-wordpress-21/

    The only thing I don’t like it about it (so far) is the fact that you can’t really export the data real well yet. Apparently, it’s a feature that is coming…

  6. zolla
    zolla

    so u intend only to change the css? or what?

  7. David
    David

    Yeah this sounds pretty pratical for who I have a lot of things waiting !

  8. Luigi
    Luigi

    Do yo think that is possible to use custom fields to assign categories to pages, and make them selctable by category with a drop down menu ?

  9. Rie
    Rie

    I’m in the mathematics seciton most of the time, but I enjoy other secitons. I sometimes answer in religion, horoscopes, politics and other secitons. Over the years, this has often caused disagreements between my contacts from each of those secitons.Or what about Y!A allowing members to control what secitons they wish to see questions and answers from other contacts?I don’t consider any seciton on Y!A as nonsense, and because I answer on a particular seciton doesn’t imply whether I am pro or con on a particular issue. Please stay on topic.

  10. It’s spooky how clever some ppl are. Thanks!

Leave a Comment



Quote selected text