Helping ordinary people create extraordinary websites!
GET OUR NEWSLETTER
Your Email:
 

WordPress Customization

By Justin Laing
2008-01-09


Meta Data / Custom Fields For Page Customization

Edit Meta Data

Meta data can be added to any blog post or page. It’s located under the edit box on the Write Post and Write Page sections of the admin interface. Look for the section called “Custom Fields”, that’s your post meta data. Each piece of meta data has a key and a value. You can use meta data to store almost anything, and you can retrieve it within the page using some template functions/tags. Here some code I use so that each page can have a custom title, description, keywords, and style rules. This code is placed within my <head></head> tags in my header.php file:

Meta Customization Code

The first section of the code loads the meta data. For example to get the title meta data I call $title = get_post_meta($wp_query->post->ID, “title”, true);. I can then use the $title variable within my code to display the title information I retrieved. The styles meta data I retrieve is a little
more complex because it is grabbing an array of styles. So if there are more than one meta data elements with the title “style” I will get all these styles within one array. The last parameter of get_post_meta determines if an array is to be returned or just single value. I loop through the array and display each style using this code: <?php foreach ($styles as $s) echo $s . “\n”; ?>.



Tutorial Pages:
» Introduction To WordPress
» WordPress Themes
» Structure Of A WordPress Theme
» Making Your New Theme
» Modifying The Header
» Blog / Post Templates
» The Post Loop
» Page Templates
» Sidebars
» Meta Data / Custom Fields For Page Customization


Originally posted on Makebeta


 | Bookmark
Related Tutorials:
» Setting Up Subversion for Development on Windows
» Stylize Your Digg Count
» Installing Apache on Windows
» Ecommerce Imagery: Persuading with Pictures
» Customizable Websites - The Definitive Guide
» 7 Usability Guidelines for Websites on Mobile Devices

Advertise with Us!


Tutorials Scripts Web Hosting Developer Manuals
Resources