rss

More creative uses for custom fields

10 Apr, 2008 Page,Single

So your client has a small area of their site that displays their contact numbers. It’s one of those small features that most sites have, but its also a feature that you don’t want to be bugged with when it changes or when they need something edited. Here’s a simple guide to how you can use custom fields for this.

Choose a page on their site that you know will be kept throughout the life of their site – Perhaps an ‘about us’ page. Create custom fields for each of their contact details, maybe:

  • Telephone: 012 345 6789
  • Fax: 012 345 6789
  • Email Address: info@site.com

Then, use your special query to call the custom field for each of those

<div id="contactdetails">
	<ul>
		<li>Telephone: <? echo get_post_meta(2, 'telephone', true) ?></li>
		<li>Fax: <? echo get_post_meta(2, 'fax', true) ?></li>
		<li>Email: <a href= "mailto:<? echo get_post_meta(2, 'email', true) ?>"><? echo get_post_meta(2, 'email', true) ?></a></li>
	</ul>
</div>

Note that in this example, ’2′ is the page_id of the about us page. Change this number to whatever the ID is of the page that you use to keep this information.

2 Comments

  1. This is really good article. Thanks for sharing.

  2. Thanks Sarah, Glad you enjoyed it.

Leave a Reply

About The WordPress Guru

Over the last 4 or 5 years, I’ve been digging into the Wonders of WordPress. From the days when the Classic theme was the shizz until now, WordPress has gone from strength to strength both as the blogging platform of choice for many big players and as a CMS with...

Learn more »