Showing posts with label General. Show all posts
Showing posts with label General. Show all posts

Tuesday 6 August 2013

Making your post links pretty

Pretty permalinks are links that are more pleasing to the eye than standard links and, ultimately, more pleasing to search-engine spiders. (See Book V for an explanation of why search engines like pretty permalinks.) Pretty permalinks look something like this:

http://yourdomain.com/2011/01/01/pretty-permalinks

Break down that URL, and you see the date when the post was made, in year/month/day format. You also see the topic of the post.

To choose how your permalinks look, click Permalinks in the Settings
drop-down list. The Permalink Settings page opens.

In this page, you can find several options for creating permalinks:

✦ Default (ugly permalinks): WordPress assigns an ID number to each

blog post and creates the URL in this format: http://yourdomain.
com/?p=100.

✦ Day and Name (pretty permalinks): For each post, WordPress generates
a permalink URL that includes the year, month, day, and post slug/title:
http://yourdomain.com/2008/01/01/sample-post/.

✦ Month and Name (also pretty permalinks): For each post, WordPress
generates a permalink URL that includes the year, month, and post
slug/title: http://yourdomain.com/2008/01/sample-post/.

✦ Numeric (not so pretty): WordPress assigns a numerical value to the
permalink. The URL is created in this format: http://yourdomain.
com/archives/123.

✦ Custom Structure: WordPress creates permalinks in the format you
choose. You can create a custom permalink structure by using tags
or variables, as we discuss in the following section.

To create the pretty-permalink structure, select the Day and Name radio
button; then click the Save Changes button at the bottom of the page.

Wednesday 24 July 2013

Content

The first pillar of my daily action on the Web is content. Although the Web has seen a growing shift away from content to community, I still believe

that content is king. Communities based around common interests fall flat unless they have the content there for people to gravitate around. Facebook groups, for example, dominate because of the wealth of content they offer: the posts, links, videos, and other media people create within that group. Without the content, the group wouldn’t exist.

Using the tag for images

When you use the WordPress image uploader to include an image in your
post or page, a Description text box appears, in which you can enter a
description of the image. (We cover using the WordPress image uploader
in detail in Book IV, Chapter 3.) This text automatically becomes what’s
referred to as the <ALT> tag.

The <ALT> tag’s real purpose is to provide a description of the image for

people who, for some reason or another, can’t actually see the image. In a
text-based browser that doesn’t display images, for example, visitors see the
description, or <ALT> text, telling them what image would be there if they
could see it. Also, the tag helps people who have impaired vision and rely on
screen-reading technology because the screen reader reads the <ALT> text
from the image. You can read more about Web site accessibility for people
with disabilities at http://www.w3.org/WAI/intro/people-use-web.
php.
An extra benefit of <ALT> tags is that search engines gather data from them
to further classify the content of your site. The following code inserts an
image, with the <ALT> tag of the code in bold to demonstrate what we’re
talking about:

<img src=”http://yourdomain.com/image.jpg” alt=”This is an ALT tag within an
image” />

Search engines harvest those <ALT> tags as keywords. The WordPress
image uploader gives you an easy way to include those <ALT> tags without
having to worry about inserting them into the image code yourself. Just fill
out the Description text box before you upload and add the image to your
post. Book IV, Chapter 3 covers in-depth information on adding images to
your site content, including how to add descriptive text for the ALT tag and
keywords.

Creating categories that attract search engines

One little-known SEO tip for WordPress users: The names you give the
categories you create for your blog provide rich keywords that attract
search engines like bees to honey. A few services — Technorati (http://
technorati.com) being one of the biggest — treat categories in WordPress like tags. These services use those categories to classify recent blog posts on any given topic. The names you give your categories in WordPress can serve as topic tags for Technorati and similar services.
Search engines also see your categories as keywords that are relevant to the content on your site. So, make sure that you’re giving your categories names that are relevant to the content you’re providing on your site.
If you sometimes blog about your favorite recipes, you can make it easier for search engines to find your recipes if you create categories specific to the recipes you’re blogging about. Instead of having one Favorite Recipes category, you can create multiple category names that correspond to the types of recipes you blog about — Casserole Recipes, Dessert Recipes, Beef Recipes, and Chicken Recipes, for example.

Creating specific category titles not only helps search engines, but also
helps your readers discover content that is related to topics they are inter-
ested in.
You can also consider having one category called Favorite Recipes and creating subcategories (also known as child categories) that give a few more details on the types of recipes you’ve written about. (See Book III, Chapter 7, for information on creating Categories and child categories.)
Categories use the custom permalink structure, just like posts do. So, links
to your WordPress categories also become keyword tools within your site
to help the search engines — and, ultimately, search engine users — find
the content. Using custom permalinks creates category page URLs that look
something like this:

http://yourdomain.com/category/category_name

The category_name portion of that URL puts the keywords right into the hands of search engines.

Writing content with readers in mind

When you write your posts and pages, and want to make sure that your con-
tent appears in the first page of search results so that people will find your
site, you need to keep those people in mind when you’re composing the
content.

When search engines visit your site to crawl through your content, they
don’t see how nicely you’ve designed your site. They’re looking for words — which they’re grabbing to include in their databases. You, the site owner, want to make sure that your posts and pages use the words and phrases that you want to include in search engines.
If your post is about a recipe for fried green tomatoes, for example, you need
to add a keyword or phrase that you think people will use when they search
for the topic. If you think people would use the phrase recipe for fried green
tomatoes as a search term, you may want to include that phrase in the con-
tent and title of your post.
A title such as A Recipe I Like isn’t as effective as a title such as A Recipe for Fried Green Tomatoes, right? Including it in your post or page content gives the search engines a double-keyword whammy.

Here’s another example: Lisa once wrote a post about a rash that she devel-
oped on her finger, under her ring. She wrote that post well over a year Book IV
ago, not really meaning to attract a bunch of people to that particular post. Chapter 6
However, it seems that many women around the world suffer from the same
rash because, a year later, that post still gets at least one comment a week.
When people do a Google search by using the keywords rash under my wed-
ding ring, out of a possible 743,000 results returned, Lisa’s blog post appears
in the top five slots.
This is how great blogs are! Lisa was actually able to solve her problem with the rash under her finger because one woman from Australia found Lisa’s blog through Google, visited her blog post, and left a comment with a solution that worked. Who says blogs aren’t useful?

Planting keywords in your Web site

If you’re interested in a higher ranking for your site, we strongly recommend using custom permalinks. By using custom permalinks, you’re automatically inserting keywords into the URLs of your posts and pages, letting search

engines include those posts and pages in their databases of information on those topics. If a provider that has the Apache mod_rewrite module enabled hosts your site, you can use the custom permalink structure for your WordPress-powered site.

Keywords are the first step on your journey toward great search engine
results. Search engines depend on keywords, and people use keywords to look for content.
The default permalink structure in WordPress is pretty ugly. When you’re
looking at the default permalink for any post, you see a URL something like
this:

http://yourdomain.com/p?=105

This URL contains no keywords of worth. If you change to a custom permalink structure, your post URLs automatically include the titles of your posts to provide keywords, which search engines absolutely love. A custom permalink may appear in this format:

http://yourdomain.com/2007/02/01/your-post-title

We explain setting up and using custom permalinks in full detail in Book III,
Chapter 3.
Optimizing your post titles for search engine success
Search engine optimization doesn’t completely depend on how you set up
your site. It also depends on you, the site owner, and how you present your
content.
You can present your content in a way that lets search engines catalog your
site easily by giving your blog posts and pages titles that make sense and
coordinate with the actual content being presented. If you’re doing a post
on a certain topic, make sure that the title of the post contains at least one
or two keywords about that particular topic. This practice gives the search
engines even more ammunition to list your site in searches relevant to the
topic of your post.
While your site’s presence in the search engines grows, more people will find your site, and your readership will increase as a result.
A blog post with the title A Book I’m Reading doesn’t tell anyone what book you’re reading, making it difficult for people searching for information on that particular book to find the post.

If you give the post the title WordPress All-in-One For Dummies: My Review, you provide keywords in the title, and (if you’re using custom permalinks) WordPress automatically inserts those keywords into the URL, giving the search engines a triple keyword play:

✦ Keywords exist in your blog post title.
✦ Keywords exist in your blog post URL.
✦ Keywords exist in the content of your post.

Optimizing Your WordPress Blog

Search engine optimization (SEO) is the practice of preparing your site to
make it as easy as possible for the major search engines to crawl and cache
your data in their systems so that your site appears as high as possible in
the search returns. Book V contains more information on search engine opti-
mization, as well as marketing your blog and tracking its presence in search
engines and social media by using analytics. This section gives you a brief
introduction to SEO practices with WordPress, and from here, you can move
on to Book V to take a real hard look at some of the things you can do to
improve and increase traffic to your Web site.

If you visit Google’s search engine page at www.google.com and do a

search for the keywords WordPress blog design, Lisa’s site at E.Webscapes
is in the top-ten search results for those keywords (at least, it is while we’re
writing this chapter). Those results can change from day to day, so by the
time you read this book, someone else may very well have taken over that
coveted position. The reality of chasing those high-ranking search engine
positions is that they’re here today, gone tomorrow. The goal of search
engine optimization is to make sure that your site ranks as high as possible
for the keywords that you think people will use to find your site. After you
attain those high-ranking positions, the next goal is to keep them. Check out
Search Engine Optimization For Dummies, by Peter Kent (Wiley), for some
valuable information on keeping those high rankings through ongoing opti-
mization of your site.
WordPress is equipped to create an environment that’s friendly to search
engines, giving them easy navigation through your archives, categories,
and pages. WordPress provides this environment with a clean code base,
content that’s easily updated through the WordPress interface, and a solid
navigation structure.
To extend search engine optimization even further, you can tweak five elements of your WordPress posts, pages, and templates:
✦ Custom permalinks: Use custom permalinks, rather than the default
WordPress permalinks, to fill your post and page URLs with valuable
keywords. Check out Book III, Chapter 3 for information on WordPress
permalinks.
✦ Posts and page titles: Create descriptive titles for your blog posts and
pages to provide rich keywords in your site.
✦ Text: Fill your blog posts and pages with keywords for search engines
to find and index. Keeping your site updated with descriptive text and
phrases helps the search engines find keywords to associate with your
site.

✦ Category names: Use descriptive names for the categories you create in
WordPress to place great keywords right in the URL for those category
pages, if you use custom permalinks.
✦ Images and ALT tags: Place <ALT> tags in your images to further define
and describe the images on your site. You can accomplish this task
easily by using the description field in the WordPress image upload

Working with Custom Post Types

A new feature in WordPress (new as of version 3.0) is a feature called
custom post types. This feature allows you, the site owner, to create different content types for your WordPress site that give you more creative control over how different types of content are entered, published, and displayed on your WordPress Web site.
Personally, we wish WordPress had called this feature custom content types so that people didn’t incorrectly think that custom post types pertain to posts only. Custom post types aren’t really the posts that you know as blog posts. Custom post types are a different way of managing content on your blog, by defining what type of content it is, how it is displayed on your site, and how it operates — but they’re not necessarily posts.
By default, WordPress already has different post types built into the software, ready for you to use. These default post types include

✦ Blog posts
✦ Pages
✦ Navigation menus (see Book VI) ✦ Attachments
✦ Revisions

Custom post types give you the ability to create new and useful types of
content on your Web site, including a smart and easy way to publish those content types to your site.
You really have endless possibilities for how to use custom post types, but
here are a few ideas that can kick-start your imagination (they’re some of the
most popular and useful ideas that others have implemented on their sites):

✦ Photo gallery
✦ Podcast or video

✦ Book reviews

✦ Coupons and special offers ✦ Events calendar
In order to create and use custom post types on your site, you need to be
sure that your WordPress theme contains the correct code and functions. In
the following steps, we create a very basic custom post type called Generic
Content. Follow these steps to create the Generic Content basic custom post
type:
1. Click Editor in the Appearances drop-down list to open the Theme
Editor page.
2. Click the Theme Functions template link to open the functions.php
file in the text editor on the left side of the page.
3. Add the custom post types code to the bottom of the Theme Functions
template file.
Scroll down to the bottom of the functions.php file and include the
following code to add a Generic Content custom post type to your site:
add_action( ‘init’, ‘create_my_post_types’ );

function create_my_post_types() {
register_post_type( ‘generic_content’,
array(
‘label’ => __( ‘Generic Content’ ),
‘singular_label’ => __( ‘Generic Content’ ),
‘description’ => __( ‘This is a description of the Generic Content type’
),
‘public’ => true,
);
}
4. Click the Update File button to save the changes made to the func-
tions.php file.

The function register_post_type can accept several different arguments and parameters, which are detailed in Table 6-2. You can use a variety and combination of different arguments and parameters to create a specific
post type. You can find more information on custom post types and using the register_post_types function in the official WordPress Codex at http://codex.wordpress.org/Function_Reference/register_
post_type.
After you complete the preceding steps to add the Generic Content custom post type to your site, a new post type labeled Generic appears in the left navigation menu of the Dashboard.

 

You can add and publish new content by using the new custom post type,
just like when you write and publish blog posts (see Book IV, Chapter 1).
The published content isn’t added to the chronological listing of blog posts,
but rather, it’s treated like separate content from your blog (just like static
pages).
View the permalink for it, and you see that it adopts the post type name
Generic Content and uses it as part of the permalink structure, creating a
permalink that looks like http://yourdomain.com/generic-content/
new-article.

✦ Custom Post Types UI: Written by the folks at WebDevStudios (http://
webdevstudios.com), this plugin gives you a clean interface within
your WordPress Dashboard that can help you easily and quickly build
custom post types on your Web site. It eliminates the need to add the
code (discussed earlier in this section) to your functions.php file
by giving you options and settings so that you can configure and build
the custom post type that you want.
✦ Verve Meta Boxes: Available from Magento Developers in the
WordPress Plugin Directory (http://wordpress.org/extend/
plugins/verve-meta-boxes), this plugin provides an interface
in your Dashboard that you can use to create meta boxes, or special
custom fields (see Book IV, Chapter 5) for the custom post types that
you build. As an example, Figure 6-7 shows some custom meta boxes
built by using custom post types. This Web site features theater produc-
tions and the custom post types for those shows.
The Purchase Link boxes were created by using custom meta
boxes and give the Web site owner a quick and easy field to fill out so
that he or she can include information on where to purchase show tick-
ets in every show post published.

Custom Styles for Sticky, Category, and Tag Posts

The method for putting a very basic WordPress
theme together, which includes a Main Index template that uses the
WordPress Loop. You can use a custom tag to display custom styles for
sticky posts, categories, and tags on your blog. That special tag looks like
this:

<div <?php post_class() ?> id=”post-<?php the_ID(); ?>”>

The post_class() section is the coolest part of the template. This tem-
plate tag tells WordPress to insert specific HTML markup in your template
that allows you to use CSS to make custom styles for sticky posts, catego-
ries, and tags.
In Book IV, Chapter 1, we tell you all about how to publish new posts to your blog, including the different options you can set for your blog posts, such as categories, tags, and publishing settings. One of the settings is the Stick This Post to the Front Page setting. In this chapter, we show you how to customstyle those sticky posts — it’s not as messy as it sounds!
For example, say that you publish a post that has the following options set: ✦ Stick this post to the front page.
✦ Filed in a category called WordPress. ✦ Tagged with News.

By having the post_class() tag in the template, WordPress inserts HTML markup that allows you to use CSS to style sticky posts, or posts assigned to specific tags or categories, with different styling than the rest of your posts. WordPress inserts the following HTML markup for your post:

<div class=”post sticky category-wordpress tag-news”>

In Book VI, you can discover CSS selectors and HTML markup, and how they work together to create style and format for your WordPress theme. With the post_class() tag in place, You can now go to your CSS file and define styles for the following CSS selectors:
✦ .post: Use this as the generic style for all posts on your blog. The CSS
for this tag is
.post {background: #ffffff; border: 1px solid silver; padding: 10px;}
A style is created for all posts that have a white background with a thin silver border and 10 pixels of padding space between the post text and the border of the post.
✦ .sticky: You stick a post to your front page to call attention to that
post, so you may want to use different CSS styling to make it stand out
from the rest of the posts on your blog:
.sticky {background: #ffffff; border: 4px solid red; padding: 10px;}
This code creates a style for all posts that have been designated as
‘sticky’ in the post options on the Write Post page to appear on your site with a white background, a thick red border, and 10 pixels of padding space between the post text and border of the post.
✦ .category—wordpress: Because Lisa blogs a lot about WordPress,
her readers may appreciate it if she gives them a visual cue as to which posts on her blog are about that topic. She can do that through CSS by telling WordPress to display a small WordPress icon on the top-right corner of all her posts in the WordPress category:

.category-wordpress {background: url(wordpress-icon.jpg) top right
no-repeat; height: 100px; width: 100px;}
This code inserts a graphic — wordpress-icon.jpg — that’s 100 pixels in height and 100 pixels in width at the top-right corner of every post she assigns to the WordPress category on her blog.
✦ .tag—news: Lisa can style all posts tagged with News the same way she
styles the categories:
.tag-news {background: #f2f2f2; border: 1px solid black; padding: 10px;}

 

This CSS styles all posts tagged with News with a light gray background and a thin black border with 10 pixels of padding between the post text and border of the post.
You can easily use the post-class() tag, combined with CSS, to create dynamic styles for the posts on your blog!

Comprehension the Framework Requirements

When you can begin blogging with Wordpress, you need to set up your base camp. Doing so includes more than basically downloading and

instating the Wordpress programming. You additionally need to create your area (your web journal location) and your Web hosting administration (the place that houses your website). In spite of the fact that you at first download your Wordpress programming onto your hard drive, you instate it on a Web host.

Getting a Web server and introducing programming on it is something you may

as of recently have done on your site; in which case, you can move onto the following

section. Provided that you haven't instituted Wordpress, you should first recognize numerous

calculates, and adapt to a studying bend, on the grounds that setting up your

write through a hosting administration includes utilizing a few innovations that you

may not feel good with. This section takes you through the rudiments

of the aforementioned innovations, and by the final page of this section, you'll have

Wordpress efficaciously introduced on a Web server with your own particular realm

name.

The Prevalent Provision of Adobe Reader

Adobe Reader, the  prevalent provision  for review Pdf records crosswise over stages and gadgets is presently ready in the Windows Phone Store for all the Windows Phone 8 clients.

The official Adobe Reader for Windows Phone permits you to gain entrance to an extensive variety of Pdf sorts incorporating the watchword secured reports. The application gives you a chance to view, open and inquiry Pdf records and gives you a chance to zoom in on content or pictures.

The route all through the Pdf substance is smooth and you can utilize the bookmarks to bounce straightforwardly to an area in your Pdf archive. Adobe Reader additionally permits you to tap on the connections in the Pdf record to open joined pages. Moreover, you can rapidly go through substantial records utilizing thumbnails and ultimately, the application gives you a chance to select and duplicate content from a Pdf record to the clipboard.

The official Adobe Reader application for Windows Phone 8 could be downloaded from the Windows Phone Store.

Using Sidebar Templates

You can create separate sidebar templates for different pages of your site by
using a simple include statement. When you write an include statement,
you’re simply telling WordPress that you want it to include a specific file on
a specific page.
The code that pulls the usual Sidebar template (sidebar.php) into all the
other templates, such as the Main Index template (index.php), looks like
this:

<?php get_sidebar(); ?>

What if you create a page and want to use a sidebar that has different infor-
mation from what you have in the Sidebar template (sidebar.php)? Follow
these steps:
1. Create a new sidebar template in a text editor such as Notepad.
2. Save the file as sidebar2.php.
In Notepad, choose File➪Save. When you’re asked to name the file, type sidebar2.php, and then click Save.
3. Upload sidebar2.php to your Themes folder on your Web server.

See Book II, Chapter 2 for FTP information, and review Book VI for infor-
mation on how to locate the Themes folder.
The template is now in your list of theme files on the Edit Themes page (log in to your WordPress Dashboard and click Editor in the Appearance drop-down list).
4. To include the sidebar2.php template in one of your page templates,
replace the code:
<?php get_sidebar(); /> with the code <?php get_template_
part(‘sidebar2’); ?> (which calls in a template you’ve created within your theme).

By using that get_template_part function, you can include virtually any
file in any of your WordPress templates. You can use this method to create
footer templates for pages on your site, for example. First, create a new tem-
plate that has the filename footer2.php. Then locate the following code in
your template:

<?php get_footer(); ?>

and replace it with this code:

<?php get_template_part(‘footer2’); ?>

You can do multiple things with WordPress to extend it beyond the blog.
The few practical examples in this chapter that use the default Twenty Ten
theme show you how to use WordPress to create a fully functional Web site
that has a CMS platform — anything from the smallest personal site to a
large business site.

Adding the tag

When you have the category ID number in hand, you’re ready to add the <query_post> tag to your template.

Here are two parameters that you can use with the <query_posts> tag:

✦ showposts=X: This parameter tells WordPress how many posts you
want to display. If you want to display only three posts, enter show-
posts=3.
✦ cat=X: This parameter tells WordPress that you want to pull posts from
the category with this specific ID number. If the ID category is 40, enter
cat=40.
Follow these steps to add the <query_post> tag to your template:

1. Click Editor in the Appearance drop-down list.
The Edit Themes page opens.
2. Click the template in which you want to display the content.
If you want to display content in a sidebar, for example, choose the Sidebar template: sidebar.php.
3. Locate the ending </ul> tag at the bottom of the template for the
theme you’re using.
If you’re using the Twenty Ten theme, the ending </ul> tag is the second-to-last line.
4. Type the following code directly above the ending </ul> tag:
<?php query_posts(‘showposts=3&cat=40’); ?>
<h2>Type Your Desired Title Here</h2>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<strong><a href=”<?php the_permalink() ?>” rel=”bookmark”
title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_ title(); ?></a></strong>
<?php the_excerpt();endwhile;endif; ?>

In the first line, you indicate the following: showposts=3&cat=40. You

can change these numbers to suit your specific needs. Just change 3 to
whatever number of posts you want to display (there’s no limit!) and
change 40 to the specific category ID number that you want to use.
5. Click the Update File button.
The changes you just made are saved to the sidebar.php template.

Finding the category ID number

You can’t easily find the unique ID number for a category unless you know where to look. To locate it, follow these steps:
1. Click Categories in the Posts drop-down list.
The Categories page opens.
2. Hover your mouse over the name of the category for which you need
the ID number.
The category ID number appears in the status bar of your browser.
Figure 6-5 shows the category ID in a browser’s status bar. (Mozilla
Firefox, Internet Explorer, and Safari have similar status bars.) The last part of the URL displayed in the status bar is tag_ID=1, which means that 1 is the ID for this Uncategorized category

Pulling in Content from a Single Category

WordPress makes it possible to pull in very specific types of content on your
Web site through the <query_posts> template tag. If you place this tem-
plate tag before The Loop (see Book VI), it lets you specify which category
you want to pull information from. If you have a category called WordPress

and you want to display the last three posts from that category — on your front page, in your blog sidebar, or somewhere else on your site — you can use this template tag.

The <query_posts> template tag has several parameters that let you dis-
play different types of content, such as posts in specific categories and con-
tent from specific pages/posts or dates in your blog archives. The
<query_posts> tag lets you pass so many variables and parameters that
we just can’t list all the possibilities. Instead, you can visit this page in the
WordPress Codex and read about the options available with this tag:
http://codex.wordpress.org/Template_Tags/query_posts.
First, you have to find the ID number for the category you want to use; then you have to tell WordPress how to display the content by using the <query_posts> tag.

Creating a Template for Each Post Category

You don’t have to limit yourself to creating a static-page template for your
site. You can use specific templates for the categories you’ve created on
your blog (which we talk about in Book III, Chapter 7) and create unique sec-
tions for your site, as Lisa did (with an espresso chaser, of course).
Figure 6-4 shows Lisa’s design portfolio. Design Portfolio is the name of a category that she created in the WordPress Dashboard. Instead of using a static page for the display of her portfolio, she used a category template to handle the display of all posts made to the Design Portfolio category.
You can create category templates for all categories in your blog simply by
creating template files that have filenames that correspond to the category
ID numbers, and then uploading those templates to your WordPress themes
directory (see Book VI). Here’s the logic to creating category templates:
✦ A template that has the filename category.php is a catchall for the dis-
play of categories.
✦ Add a dash and the category ID number to the end of the filename
to specify a template for an individual category.

✦ If you don’t have a category.php or category-#.php file, the cat-

egory display gets defined from the Main Index template (index.php).

 

Creating Different Page Views Using WordPress Templates

The Add New Page page opens, where you can write a new post to your WordPress blog.

1. Click Add New in the Pages drop-down list.

2. Type the title in the Title text box and the page content in the large
text box.
3. Select the page template from the Page Template drop-down list.
By default, the Page Template drop-down list in the Attributes module appears on the right side of the page. You can reposition the modules on this page; see Book III, Chapter 2 for more information.
4. Click the Publish button to save and publish the page to your site.

Figure 6-2 shows the layout of Lisa’s home page on her business site at
www.ewebscapes.com and the information it contains, whereas Figure 6-3
shows the layout and information provided on the Services page at www.
ewebscapes.com/services. Both pages are on the same site, in the same WordPress installation, with different static-page templates to provide different looks, layouts, and sets of information.

A lot of the content in this chapter dips into working with WordPress tem-

plates and themes, a concept that gets introduced, in depth, in Book VI. If
you find the topics in this chapter intimidating at all, then work through

How to Create a Template

To use a page template, you have to create one. You can create this file in a text-editor program, such as Notepad. (To see how to create a template, flip over to Book VI, which gives you extensive information on WordPress templates and themes.) To create an About page, for example, you can save the template with the name about.php.
When you have your template created, follow these steps to make it part of WordPress:

1. Upload the template file to your WordPress theme folder.
You can find that folder on your Web server in /wp-content/themes.
2. Log in to your WordPress Dashboard and click Editor in the
Appearance drop-down list.
The Edit Themes page opens.
3. Click the about.php template link located on the right side of the
page.
4. Type the Template Name tag directly above the get_header() tem-
plate tag.
The header tag looks like this: <?php get_header(); ?>.

If you’re creating an About Page, the code to create the Template Name looks like this:

<?php
/*
Template Name: About Page
/*
?>
5. Click the Update File button.
The file is saved, and the page refreshes. If you created an About Page template, the about.php template is now called About Page in the template list on the right side of the page.
Figure 6-1 shows the Page template and displays the code needed to define

Using WordPress Templates

As we explain on the previous posts , a static page contains content that
doesn’t appear on the blog page, but as a separate page within your site.
You can have numerous static pages on your site, and each page can have
a different design, based on the template you create. (Flip to Book VI to find out all about choosing and using templates on your site.) You can create several static-page templates and assign them to specific pages within your site by adding code to the top of the static-page templates.

Here’s the code that appears at the top of the static-page template Lisa uses
for her About Us and Our Blog Designers page at www.ewebscapes.com/
about:

<?php
/*
Template Name: About Page
*/
?>

Using a template on a static page is a two-step process: Upload the template,
and then tell WordPress to use the template by tweaking the page’s code.

In Book VI, you can discover information about Custom Menus, including
how to create different navigation menus for your Web site. You can create
a menu of links that includes all the pages you created in your WordPress
Dashboard. You can display that menu on your Web site by using the
Custom Menus feature.

Exploring Different Uses for Custom Fields

In this chapter, we use the example of adding your current mood to your
blog posts by using Custom Fields. But you can use Custom Fields to define
all sorts of different data on your posts and pages; you’re limited only by
your imagination when it comes to what kind of data you want to include.
Obviously, we can’t cover every possible use for Custom Fields, but we can give you some ideas that you may want to try out on your own site — at the very least, you can implement some of these ideas just to get yourself into the flow of using Custom Fields, and hopefully they can spark your imagination on what types of data you want to include on your site:
✦ Music: Display the music you’re currently listening to. Use the same
method we describe in this chapter for your current mood, except
create a Custom Field named Music: Use the same code template, just
define the key as: $key=”music”; and alter the wording from My
Current Mood is: to I am Currently Listening to:.
✦ Books: Same as the mood or music Custom Field, you can display what
you’re currently reading by creating a Custom Field named Book and
define the key in the code as $key=”book”;, and then alter the wording
from My Current Mood is: to I Am Currently Reading:.
✦ Weather: Let your readers know what the weather is like in your little
corner of the world by adding your current weather conditions to your
published blog posts. By using the same method that we describe in this
chapter, create a Custom Field named Weather and use the same code
for the template, just define the key as $key=”weather”; and alter the
wording from My Current Mood is: to Current Weather Conditions:.
If you want to get really fancy with your Custom Fields, you can also define an icon for the different metadata displays. For example, using the mood Custom Field, you can add little emoticons (or smiley-face icons that portray mood) after your mood statement to give a visual cue of your mood, as well as a textual one. Follow these steps to add an emoticon to the mood Custom Field that you add in theprevious sections in this chapter:

1. Visit the Posts page in the Dashboard.
2. Click the title of the post that you want to edit.
3. Add a new Custom Field by selecting Enter New from the drop-down
list and entering mood-icon in the Name text box.

4. Click the Add an Image icon above the Post text box to open the

Upload Image window.
Upload an image from your computer by clicking the Select Files button (see Book IV, Chapter 3 for information on uploading images).
5. From the Link URL text box, copy the file URL of the image you
uploaded.
You can see the Add an Image window in Figure 5-6.

6. Click the X in the top-right corner to close the Add an Image window.

7. Paste the Link URL in the Value text box for the mood-icon Name (see

Figure 5-7).
8. Click the Add Custom Field button.
The Name and Key values are saved.
9. Click the Update button.
This step saves the changes in your post and updates it on your site.
10. Update the function code in your template file to include the new
mood icon.
Follow these steps to add that code:

a. Open the Edit Themes page in your Dashboard.

b. Click the Single Page (single.php) file.
The single.php template displays in the text box on the left side of
the page.
c. Locate the code you added for the mood Custom Field.
d. Before the closing </strong> HTML tag, add the following line of
code:
<img src=”<?php $key=”mood-icon”; echo get_post_meta($post->ID, $key,
true); ?>” />
The <img src=” that precedes the Custom Field code is the HTML tag used to display an image on your site. The “ /> code that
appears after the Custom Field code is part of the HTML tag and it closes the <img src=” HTML tag. We changed the $key to indicate that we’re calling the mood-icon Custom Field.
e. Click the Update File button to save your changes.
f. Visit the post on your site to view your new mood icon.
You can see Lisa’s mood icon in Figure 5-8.

The entire snippet of code you add in the preceding steps should look like this, when put all together (be sure to double-check your work!):

<?php if ( get_post_meta($post->ID, ‘mood’, true) ) : ?>
<p><strong>My Current Mood is: <?php $key=”mood”; echo get_post_
meta($post->ID, $key, true); ?> <img src=”<?php $key=”mood-icon”;
echo get_post_meta($post->ID, $key, true); ?>” /></strong></p> <?php endif; ?>