Enhance your custom theme – Part 2

Step 1: Add quotes using custom fields

From a WordPress point of view, custom fields have been around the longest and they are useful in some very simple instances.

Within each section of our admin, you will notice a tab in the top right hand corner called screen options. If you navigate to one of your page admin section, hit the tab, select the one marked “Custom Fields” and close the screen options.

A new content area called Custom Fields should now be available on your admin panel.

Each custom field is extra information known as meta-data and is composed of a key and a value.

One way to enhance our theme would be to add quotes on our pages instead of listing the blog categories in our sidebar. To do this, we’ll create a custom field for each page.

On our about page, let’s create a new custom field called page-quote and let’s add a quote. Repeat this process on all pages.

To display the quotes on our page, we will use the function get_post_meta(); inside your loop in the page.php template.

 <?php echo get_post_meta($post->ID, 'page-quote', true); ?>

Comments are closed.