PureNews

PureNews is an amazingly sleek and powerful news theme with unlimited color variations.

View full feature list Check out the live demo Buy this theme today

Custom Fields

I am working on a new site for an online publication From My Bottom Step and I wanted to be able to allow authors to display external links from the post and additional resources in the sidebar or the footer of the post like some major newspaper sites do. To do so I enlisted them help of a little used wordpress feature, custom fields.

The issue however was that I wanted it to be brain dead simple for authors to use. I didn’t want them to have to format the links with html and unordered lists, and that made it a bit tricky. So the final solution I came up with requires the author to use a new field for each link, but use the same key.

I called the key extlink, and used the code below to display the whole thing in one list. If there are no extlink fields selected then it wont display the block. If it does however it will display the header for the block, and the links below it.

[sourcecode language='php']
< ?php $links = get_post_custom_values("extlink");
if ($links[0]!="") {
$mykey_values = get_post_custom_values('extlink');

echo "

John Leschinski is the creative director and founder of Leschinski Design. John's skill and talent is sought after by large and small companies and organizations, both local to the Rainy River district, London Ontario, and globaly. His experience and knowledge are also used in classrooms to groom the next generation of web developers and business seminars discussing e-commerce and the value of good design.

3 comments - Leave a reply
  • Posted by Baz L on 3rd Aug 2008

    So where exactly does this code go?

  • Posted by Andrew Flusche on 3rd Aug 2008

    This is one of my favorite tips of yours. It certainly got a bookmark from me. Several times I've wanted to do something similar, but I never quite new how to make custom fields handle it. Now I do!!

  • Posted by Stephen Lee on 8th Aug 2008

    Great tip. I'm going to incorporate this in my blog. Thank you.