Cover Page

WordPress®
24-Hour Trainer

Third Edition

George Plumley

 

 

Wiley Logo

This book is dedicated to the memory of my mother, Adelaide, who passed away during its writing, and to the memory of my father, Stan. It is also dedicated to my wife, Kim, and daughters, Grace and Ella, my sister, Patricia, and my in-laws, Gord and Carole—your support and encouragement always mean the world to me.

About the Author

image

GEORGE PLUMLEY has been developing small business websites since 1993 and has worked almost exclusively with WordPress since 2007. In addition to writing about WordPress, he does live online coaching and produces video training series for VTC.com and Infinite Skills. He lives on Vancouver Island where he tries to go offline at least a couple of hours each day.

About the Technical Editor

JOHN PELOQUIN is a software engineer with over 10 years of web development experience. John earned his B.A. in Mathematics from U.C. Berkeley and is currently a lead engineer for a healthcare technology startup where he makes heavy use of MySQL, PHP, and JavaScript (the technologies upon which WordPress is built). John has used WordPress to build custom content management solutions for a variety of professional and personal projects. Prior to editing this volume, John edited Professional Website Performance by Peter Smith (Wiley 2012) and Professional JavaScript for Web Developers, 3rd ed. by Nicholas Zakas (Wiley 2012). When he is not coding or collecting errata, John can sometimes be found doing stand-up comedy at open mics in NYC.

Credits

EXECUTIVE EDITOR
Carol Long

PROJECT EDITOR
Chris Haviland

TECHNICAL EDITOR
John Peloquin

PRODUCTION EDITOR
Rebecca Anderson

COPY EDITOR
San Dee Phillips

MANAGER OF CONTENT DEVELOPMENT & ASSEMBLY
Mary Beth Wakefield

MARKETING DIRECTOR
David Mayhew

MARKETING MANAGER
Carrie Sherrill

PROFESSIONAL TECHNOLOGY & STRATEGY DIRECTOR
Barry Pruett

BUSINESS MANAGER
Amy Knies

ASSOCIATE PUBLISHER
Jim Minatel

PROJECT COORDINATOR, COVER
Brent Savage

PROOFREADER
Jen Larsen, Word One New York

INDEXER
Johnna VanHoose

COVER DESIGNER
Wiley

COVER IMAGE
©Getty Images/Westend61

Acknowledgments

I WANT TO THANK Carol Long for her guidance and patience over the years, the whole Wiley team, in particular the editors headed by Chris Haviland, who had to deal with more than just a third edition, San Dee Phillips, who kept my voice consistent and my syntax clear, and John Peloquin for many helpful technical suggestions. Thanks also to my wonderful agent, Carole Jelen, for her keen insights into publishing and for being my cheering section, the programmers who make WordPress possible, and the WordPress community from whom I've learned and continue to learn so much. Finally, I want to thank all my clients and students over the years who, by asking great questions, have helped me learn to explain things more clearly.

Introduction

IN THE FEW SHORT YEARS since the first edition of this book, WordPress has grown to power about 20% of all the websites in the world. This success is not due to some massive marketing campaign; it was mostly viral, as web site owners, designers, developers, and marketers spread the word. And I think they told others because WordPress is:

It's this last quality—ease of growing and adapting—which I think is particularly important. WordPress helps make your website future-proof, meaning no matter what happens on the web—new social media platforms, new technologies, new requirements—it allows you to respond pretty easily to those changes.

Since I began building websites exclusively with WordPress, I've noticed an important change in my clients: they look forward to updating and expanding their sites. When changing some text, let alone adding a new page, is like pulling teeth, you're less likely to do it. With WordPress, not only are my clients making their own changes, but they're excited about it and that's also made them more involved in their sites. Instead of having a site built and then sitting back, my clients are actively thinking about what they can change or add to make their sites better, because they can go in and do it themselves when the thought strikes.

That's the real power of WordPress: putting more control in the hands of the website owner.

But WordPress won't magically build a great site for you. It's only a tool that makes it easier for you to build a great site. You need to know how to use WordPress, as well as understand its potential, so you can use the tool most effectively. This book will help you with both.

Who This Book Is For

This book is for beginners at two levels: those who've never built a website and those who've never built or used a WordPress website. You should be aware that there are two versions of WordPress:

The important difference between the two is that with the hosted version you don't control which plugins or themes are available to use. For personal blogging or, with some paid features, even some small businesses, the hosted version can be a good choice. But for complete control or customization of your site, the self-hosted version is the better choice.

Though this book deals with the self-hosted version of WordPress, much of it—how to enter content, how to upload photos and documents, how to lay out content, and so on—still applies to the hosted version.

What This Book Covers

Since the second edition of this book, WordPress has undergone significant changes, all of which make it even easier to use and even more flexible for managing any type of website. This new edition includes features up to and including Version 4.0, with indications of some changes expected in 4.1.

You'll learn how to set up a WordPress website from scratch, using the default features of the software. Each lesson covers a related set of tasks, so you can follow the lessons in order or easily dip into any one of them to quickly learn one thing. Because we're in an increasingly mobile world, the book also covers important differences when using WordPress on a mobile device. And at the end of most lessons there will be a list of free plugins that extend the functions discussed in that lesson.

Keep in mind, this book is not what I call an extended manual. It does not aim to cover every feature of WordPress. Instead, it focuses on the key tasks you need in the day-to-day running of a website, and covers them in great detail. I do that by showing you not just the basics, but the tips and tricks that make things as simple as possible. The addition of videos for key points helps make things clearer and reinforce the concepts.

How This Book Is Structured

The 36 lessons are grouped into themed sections:

When you're finished reading the book and watching the videos online, you'll find lots of support in the p2p forums, as you'll see in a moment, but there's also the WordPress community on the Web. Hundreds of thousands of people around the world are using this software, and a lot of them give back in so many ways. It's a spirit that's reflected in the quality of WordPress and its continued improvement.

From the people who created and maintain WordPress, to the people who make plugins and themes, to the people who write about WordPress on their blogs or contribute to the official and unofficial forums, there are thousands of bright minds giving back to the community with code, ideas, fixes, and more. You never have to feel you're alone when you're using WordPress. I like to think of it as a worldwide 24-hour help line. Whether you need help or can offer help, you're welcome any time.

Instructional Videos

Nothing beats watching how something is done, and that's why I've provided several hours' worth of video about how you can use WordPress. Most lessons in the book have an accompanying video which not only illustrates several of the examples in the lesson, but goes well beyond what can be covered in print. You'll also gain more insight into the creation of the sample website discussed in the book: Island Travel.

If you have an existing WordPress site—a self-hosted version or a blog on WordPress.com—I encourage you to work along in the admin screen. If you don't have a site, you could install WordPress if you have a web hosting account (see Lesson 3) or you could open an account with WordPress.com. The main thing is that you be able to practice what's covered in the book and on these videos, which can be viewed at www.wrox.com/go/wp24vids.

Also online you'll find a PDF with links to each of the more than 400 plugins mentioned in the book. You can find the plugins under the lesson where they were mentioned. Click on a link and you'll be taken to the listing in the WordPress.org Plugin Directory.

Conventions

To help you get the most from the text and keep track of what's happening, we've used a number of conventions throughout the book.

As for styles in the text:

Errata

We make every effort to ensure that there are no errors in the text or in the code. However, no one is perfect, and mistakes do occur. If you find an error in one of our books, like a spelling mistake or faulty piece of code, we would be very grateful for your feedback. By sending in errata, you may save another reader hours of frustration and, at the same time, you will be helping us provide even higher quality information.

To find the errata page for this book, go to www.wrox.com and locate the title using the Search box or one of the title lists. Then, on the Book Search Results page, click the Errata link. On this page, you can view all errata that has been submitted for this book and posted by Wrox editors.

If you don't spot “your” error on the Errata page, click the Errata Form link and complete the form to send us the error you have found. We'll check the information and, if appropriate, post a message to the book's errata page and fix the problem in subsequent editions of the book.

p2p.wrox.com

For author and peer discussion, join the P2P forums at p2p.wrox.com. The forums are a web-based system for you to post messages relating to Wrox books and related technologies and interact with other readers and technology users. The forums offer a subscription feature to e-mail you topics of interest of your choosing when new posts are made to the forums. Wrox authors, editors, other industry experts, and your fellow readers are present on these forums.

At p2p.wrox.com, you will find a number of different forums that will help you not only as you read this book, but also as you develop your own applications. To join the forums, just follow these steps:

  1. Go to p2p.wrox.com and click the Register link.
  2. Read the terms of use and click Agree.
  3. Complete the required information to join, as well as any optional information you wish to provide, and click Submit.
  4. You will receive an e-mail with information describing how to verify your account and complete the joining process.

Once you join, you can post new messages and respond to messages other users post. You can read messages at any time on the Web. If you would like to have new messages from a particular forum e-mailed to you, click the Subscribe To This Forum icon by the forum name in the forum listing.

For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to questions about how the forum software works as well as many common questions specific to P2P and Wrox books. To read the FAQs, click the FAQ link on any P2P page.

Section I
Before You Start

Lesson 1: Thinking Like WordPress

Lesson 2: Planning Your Site for WordPress

Lesson 1
Thinking Like WordPress

WordPress provides you with the tools to create, organize, and update your website content. Those tools function in specific ways, just as one type of word processing software has its specific buttons for creating, say, lists. But there's a difference between knowing which button to press to create a list and thinking about ways to use lists in your documents. That's what this lesson is about: learning to think like WordPress so that you can build or rebuild your website in an efficient and flexible manner from the start, and to use it in new and useful ways.

The driving principle behind this way of thinking is: Store everything in the smallest possible piece; then assemble as needed. It's the way of the digital world—photographs assembled out of pixels, data stored in database fields, or video recorded in bytes. WordPress operates with this kind of thinking, and you can make better use of its power if you think of your website and its content in this way.

Static Versus Dynamic Web Pages

If you right-click while viewing a page in your web browser, you'll see a tool called View Source, which displays the HTML of the page you're currently viewing. If you try this tool, it appears as though you're viewing a single file, but for most websites today, that's an illusion. In most cases there is no corresponding file sitting on a web server. Instead, the server has combined dozens and dozens of files in a split second to create what you're seeing with View Source.

That was not the case in the early days of the Internet, when most web pages were stored as single HTML files. The fact that no assembly was required to produce the code you see in your browser is why they are called static files. They're easy to create and they load quickly (an important factor at a time when computers and Internet speeds were slow), but they aren't flexible. Suppose you decided to change the logo at the top of each of your website's pages, and it had a new file name. With static files, you would need to manually go in and replace the HTML in every file. Not so bad on a 5-page site, but what if you had 5,000 pages? Yes, there's such a thing as search-and-replace functions in HTML editors, but aside from the fact that methods like that are not user-friendly, they solve only one limitation of static files. Suppose you wanted an entirely different header area depending on what part of your site the visitor is on?

The answer is to break up the structure of web pages in such a way that different files control different parts of the final page. So instead of storing web pages as single files, the server would store a series of files that are then assembled into a single file at the moment the page is requested by someone's browser. It is this assembly process that leads us to refer to these types of web pages as dynamic. Figure 1.1 shows one way to split up a static HTML file.

image

Figure 1.1

Notice in Figure 1.1 that the only file that would be unique to this particular web page is content html. The rest of the files—header, footer, and so on—would be shared by the other pages on the site. So changing that logo for 5,000 pages would simply be a matter of changing the header.html file. If you can start thinking of your web pages in this way—as a set of parts that can be assembled on-the-fly in different ways—you're more likely to think of ways to use this ability to your advantage.

For example, it could be that the actual content of a web page (the material in content.html in Figure 1.1) might be broken down further to allow for greater flexibility. News stories, press releases, or testimonials are good instances of this kind of content. Using testimonials as an example, you can see in Figure 1.2 how dynamic web page thinking could be applied:

image

Figure 1.2

Although the value of dynamic web pages is obvious, the concept is not of much use to website owners unless the files required to run them are easy to manage. You could build a dynamicwebsite—even a sophisticated one—with just a set of simple text files. But that would require the website manager to know HTML and other assorted languages, and to be comfortable working with tools such as file transfer programs. Moving those simple text files into a database to increase their flexibility only further complicates the work of the website manager. Enter the content management system, or CMS.

Content Management Systems

Most of us tend to think of a CMS merely as a way to avoid having to learn HTML, but editing the text and media on a web page is just a part of what a CMS does. A content management system is a user interface for dynamic web pages.

Imagine for a moment you had a CMS that provided only a WYSIWYG interface for the full HTML of each individual web page. If you had a 5-page website that rarely changed, that might be enough. But suppose, even on a 5-page website, that you decided you didn't like the top section or header that appears on all the pages of your site. Yes, the CMS makes it easy to drag and drop a new graphic into the header area of the pages, but you'd still need to change the graphic on all 5 pages separately. Now imagine that task on a site with 500 pages or 5,000! Even with search-and-replace capabilities, you would need to upload all 5,000 pages back onto the server to replace the old version, and then do it all again for the next change. Ouch!

A CMS, however, is much more than a WYSIWYG editor. You want the CMS to keep separate all those elements of a dynamic web page that you saw earlier: the header, footer, sidebar, and so on, and to manage not only their contents, but also how they interact with each other. A CMS instructs the server how to assemble any particular web page based in part on elements you control using its interface.

From the look of the page to which sidebar elements to include, a CMS provides ways for nontechnical users to control their web pages. The question then becomes: Does your CMS offer a lot of control and an easy-to-use interface?

Why Choose WordPress?

There's no shortage of content management systems these days—good ones—but the reason for choosing WordPress as your CMS is twofold:

  • The simplicity and flexibility of WordPress's design make it easy to learn, easy to expand, and easy to customize.
  • The WordPress community is so large and so vibrant that you have a huge number of add-on functions and designs to choose from, as well as excellent support, and will have for years to come.

It's important to keep in mind that no CMS can fulfill everyone's needs right out-of-the-box. The more a CMS tries to be all things to all people, the more bloated it becomes, and that means a steeper learning curve and a greater chance it will break down. A good CMS follows the principles of digital thinking and keeps as many elements separate as possible, meaning each one is fairly simple but when assembled offers great power.

WordPress is built on this principle. The core software does only basic functionality, to which you then easily add other functions as you need them or remove them when you don't. The look of WordPress is entirely separate from the core software, so it, too, is easily changed. And all these elements outside the core can be modified or new ones can be created to match your exact needs.

But even the best CMS is only as useful as the community that supports it, and WordPress has community. Whether there is someone building new add-on functionality, offering advice in forums and blog posts, or selling development services, WordPress is the most-supported CMS on the planet.

How WordPress Assembles Pages

Part of thinking like WordPress is having a general grasp of how it works. There are four elements of WordPress that interact to create HTML pages: the core files, the theme files, plugin files, and the database.

The core is the set of files that you download from WordPress.org that provide not only the basic functionality, but also the coordination between all the other elements.

The theme files have two key functions: Provide the set of HTML files that assemble the final web pages, and control the design of those pages.

Plugins are groups of files that add more functionality to WordPress. Some plugins consist of a single file, whereas others can have dozens or even hundreds.

The database has several functions. It keeps track of all the parameters of your WordPress installation, from which themes and plugins you have to the preferences of each individual user. It also stores the text portion of your content. When you write a blog post, for example, it is stored in the database, along with any references to media files, which are stored in folders on the server.

Figure 1.3 shows a simple diagram of how these four elements interact.

image

Figure 1.3

The arrows going back and forth between the elements begin to demonstrate the incredible amount of interaction required to generate a web page in a matter of seconds. The number of requests or queries made to the database averages approximately 40 or 50 for a typical WordPress page. Dynamic web pages are not cheap. They can place a heavy load on server resources if a lot of people try to access the site at one time. That's why many sites use a caching system with their CMS, which means that snapshots are taken of each page and stored as single, static HTML pages, avoiding all the back and forth between files and the database. The caching system keeps track if any changes are made to a page and takes a new snapshot as needed. That way you have the advantages of both dynamic page generation and static page serving.

The advantages of keeping these four elements of WordPress separate are many. Changing the look of your site is as simple as changing the theme. If a plugin starts causing problems for your site, you simply remove it and plug in a new one. If a new social media platform becomes the next big thing, someone will come up with a plugin to interact with it—or you can have your own made. When WordPress needs updating, your site's options and preferences remain untouched in the database. And if your host gives you poor service, you just copy all the files and the database, and move them to a new server.

But, although WordPress by its nature as a CMS and through its particular design produces dynamic web pages, its built-in tools can go only so far. Sites using WordPress can be more or less dynamic in nature depending on how the user works with WordPress's tools. Some of the power and flexibility in your site comes down to you.

Your Role in Making Your Site Flexible

As mentioned earlier, a good CMS needs to have a simple user interface, and WordPress lives up to this requirement. Actually, it was that ease of use that first led me to use WordPress on my clients' sites. Even as it has grown more complex, the developers of WordPress have continually worked to keep the interface user-friendly.

The menu system, for example, enables an unlimited number of menus; each can handle dozens and dozens of menu items with multiple levels of drop-downs, and those menu items can be virtually any type of content within WordPress: pages, posts, categories, tags, and more. Yet, as you can see in Figure 1.4, all this complexity is handled with simple check boxes, drag-and-drop interfaces, and drop-down selections.

image

Figure 1.4

But with great power comes great responsibility. You're the one who has to create a useful and easy-to-follow navigation system for your users; WordPress cannot do that for you. It just makes it easy for you to do the creating. The more you can understand what's possible with WordPress, the better you'll become at making use of its powerful tools to create the best website for your visitors.

Understanding the difference between two ways of handling content in WordPress is particularly important to making your site easier for you to use and more useful to your visitors, and that is the difference between posts and pages.

Posts and pages share a lot of similarities, in particular the way their user interfaces or, in WordPress terminology, their admin screens work (which means there are many functions you'll have to learn only once). Where they differ brings you to the heart of the principle in this lesson: Store everything in the smallest possible pieces.

Take testimonials. For many websites it is absolutely crucial to have testimonials from satisfied customers or clients. So you grab those e-mails and letters people have written praising your services and you open up WordPress. You want a web page of all those testimonials, so under Pages in the WordPress menu, you select New Page. The WYSIWYG editor makes it easy to copy the text over from your e-mail or Word document, add any extra formatting, and get the page looking nice indeed.

Fast forward 6 months, and you decide that you would like to group some of the testimonials onto another web page because they all relate to a particular service. Not so bad; you just copy the text of the page, create a new WordPress page, paste it in, and then delete the testimonials you don't need. Then a month later you get a new testimonial that belongs on both pages. You copy and paste into both. But suppose you have several categories of testimonials; you can see how this could get both tedious and complex to manage.

Remember earlier in this lesson the diagram of the testimonials page (refer to Figure 1.2) and how you might break it up instead into individual testimonials? Well that's what posts in WordPress are for: groups of related content that you can categorize. That's all we mean when we talk about a blog: groups of similar content. So now, instead of putting all the testimonials in a WordPress page, you can create a category of posts called Testimonials and enter individual testimonials as posts, assigning them to that category. Then put the category on your site menu, and when visitors click that link, WordPress gathers all the relevant posts and outputs them as a single web page.

Fast forward 6 months again and you decide you need a category of testimonials for a particular service. Just create a subcategory of Testimonials called, say, Workshop Testimonials. Through an easy WordPress interface, you can assign 2, 20, or 200 testimonials to that new category with a single click. Then you just put the Workshop Testimonials on your menu or create a link to the category wherever you want. When visitors click, they see only testimonials about your workshop.

By keeping those testimonials individual, the possibilities are endless. Need rotating testimonials on the front page? Want to feature a particular testimonial on the sidebar of a specific page? It's only possible by keeping them as separate posts. That's the power of thinking like WordPress. In the next lesson you start applying that thinking to a sample site, and throughout this book you see ways to use WordPress's tools to increase the power and flexibility of your site.

Try It

There isn't anything specific to try based on the material in this lesson, but one thing you can do is examine your favorite news website, and in the content area of the site, try to image how those pieces of content might be separated in the site's CMS. Then go to another page, compare what's common with the previous page, and try to imagine how the builders have divided up the structure of the page—map it out on paper.