More creative uses for custom fields
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: email@example.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.