Tao of WordPress - DEMO
Tao of WordPress - DEMO
Welcome
1 The Way of WordPress
2 One way, many paths
3 Who should read this book
3 WordPress enlightenment
4 What you will learn
4 Skill requirements
5 About the book
Code examples
Free WP theme
Free updates
Feedback
6 Layout conventions
6 Getting help
7 Follow the path…
The Tao of WordPress
iv
Table of Contents
v
The Tao of WordPress
vi
Table of Contents
vii
The Tao of WordPress
139 Why security is important All-in-one plus monitoring & login security
Five focused plugins
140 Security is for everyone
Minimalist plugin combination
141 WordPress is secure.
154 Advanced security techniques
141 Security of themes & plugins
Blocking bad bots
142 First line of defense = common sense
Protect your site with a firewall or blacklist
143 Controlling access
Controlling proxy access
144 Hardening WordPress Protect comments-post.php
Disable version info
Prevent hotlinking
Delete install.php
162 Checking security of plugins & themes
Protect the configuration file
Use a plugin to check other plugins
Protect the admin directory
Use a plugin to check themes
Secure the uploads directory
Testing in debug mode
149 Improving security with plugins
164 Security lockdown
Login protection
166 More security help
Firewall
166 Onward..
File monitoring
Activity monitoring
Security scanning
“All-in-one” security
Honorable mention
viii
Table of Contents
225
Stay on the path
Customize via plugin
Techniques
226 Customize via widget 250 Integrate social media
227 Customize via shortcode Social media sharing
Display a snippet of text Twitter
Display the current date Facebook
Display a link to the homepage Google
229 Customize by choosing a new theme Other social media services
229 Customize via theme settings 257 Serve mobile-friendly web pages
230 Customize via theme template files 259 Use WordPress outside of WordPress
Example 1: Changing fonts with CSS 260 Embed syndication feeds
Example 2: Create a custom page
Example 3: Customize the footer
x
Table of Contents
262
265
E-commerce & shopping carts
Forums & bulletin boards
Tips & Tricks
267 Galleries & slideshows 287 Tao of WordPress Theme
269 Lightboxes & sliders 288 Add a logo to the header
Lightboxes 289 Customize featured images
Sliders 290 Customize post formats
272 Set up a chat forum 291 Display read-more links
Styling the chat form
292 Add new widgets via child theme
Require login to view content
293 Integrating Contact Form 7
276 Enable visitors to submit content
294 Import files into the Media Library
Displaying uploaded images
295 Displaying audio and video
278 Customize the Dashboard
296 Autosave, revisions, and post locking
279 Customize the Toolbar
Autosave
280 Ajaxify WordPress Revisions
Ajax-powered comments
Post Locking
Ajax-powered contact forms
Customizing autosave and revisions
Ajax-powered login & registration
298 Infinite scrolling for posts
Ajax-powered search
299 Display blog posts on their own page
Ajax-powered themes
xi
The Tao of WordPress
Appendix
309 Getting help with WordPress
310 Troubleshooting
xii
Table of Contents
xiii
“Move and the way will open.”
— zen proverb
Welcome
In the philosophy of Taoism, the “Tao” refers to the “way” of the universe. 1 The Tao
is the experience of life, with all of its fullness, emptiness, and constant change. 2 To
live in harmony with the Tao is to “go with the flow” of nature, toward greater levels
of understanding, simplification, and efficiency. 3
1
The Tao of WordPress
2
Welcome : Who should read this book
WordPress enlightenment
WordPress is a vast topic, with endless documentation, tutorials, tricks, and tips
available online, in books, podcasts, screencasts and slideshows. And it’s all available
to anyone — 24 hours a day, seven days a week, 365 days a year. 1
Unless you know where to begin and how to proceed, however, the endless ocean
of WordPress information can be overwhelming. But there’s no need to learn it all,
or even hire someone else to do it for you. All you need is WordPress, this book, and
your imagination. Once you begin, WordPress enlightenment is inevitable.
Getting started with WordPress is easy. Once you get to know the software and
its potential, what you do with it is entirely up to you. Whether it’s configuring
the default theme, customizing your own, or even creating advanced designs,
1. Official sources of WordPress information:
WordPress provides an efficient, flexible platform that makes it all possible.
@ https://wordpress.org/
@ https://wordpress.org/news/
@ https://planet.wordpress.org/
3
“Do, or do not. There is no try.”
— yoda
Preparation
Everyone needs a plan. Even if it’s a plan to do nothing, at least you know what’s
going on. When working with software, it’s a good idea to have an understanding of
what it does, how it works, and what’s involved. This chapter provides an overview
of the entire process, explains the required tools, and delivers a plan of action for
getting started with WordPress.
• Web-based service that requires registration • Self-hosted WordPress on your own server
• Advertisements may appear on your site • No ads on your site (unless you put them there)
• Limited storage (paid upgrades available) • Unlimited storage (based on your hosting plan)
• Limited customization options, no plugins • Unlimited customization options, plugins, etc.
• Your site’s URL will be “whatever.wordpress.com” • Your site URL will be whatever you choose
• No access to files or database • Full access to files and database
• All updates performed by WordPress.com • You perform all updates of themes, plugins, and core files
• Get a free account @ https://WordPress.com/ • Download WordPress free @ https://WordPress.org/
5
The Tao of WordPress
Or, if you choose WordPress.org, you’ll find a good web host, register your own
domain name, and host WordPress on your own server. Self-hosting means that you
have full control over every aspect of your site, including the database and all files.
Self-hosted WordPress unlocks its full potential.
Each account at WordPress.com provides a
user-dashboard with blogs, stats, and more.
So which path to choose? Signing up for a hosted account is fast, free and easy. If
you love it, great. Skip ahead in the book to the configuration chapter and continue
from there. Then, when you’re ready to take it to the next level with self-hosted
WordPress, you’ll benefit from any experience acquired using WordPress.com.
That said, the majority of this book is for self-hosted WordPress. From this point
WordPress.com is perfect for
forward, you’ll learn about every step of the process, from installation and small blogs, WordPress.org is
configuration to optimization and security. Before unlocking the full potential of perfect for any website.
WordPress, let’s “zoom out” for a quick overview of the road ahead.
Roadmap
Here is a general overview for creating websites with self-hosted WordPress:
1. Find a good web host, set up your domain, and create a database
2. Download WordPress, unzip the files and upload to your server
3. Edit the WordPress configuration file with database credentials
4. Install WordPress using its “famous 5-minute installation”
5. Configure your site’s settings via the WP Admin Area
6
Preparation : Required time
Once WordPress is installed, your site is essentially ready to go. If one of the default
themes suits your needs, then you can jump right in and start adding content. Or, if
the default themes aren’t exactly what you had in mind, you can begin customizing
WordPress. From the comfort of the Admin Area, customizing WordPress is as easy
as trying new themes, installing plugins, and configuring widgets and settings.
If existing themes and plugins don’t get you there, you can venture further into
WordPress by creating and customizing your own. This involves working with code,
and enables you to create original designs with unique functionality.
‘Twenty Nineteen’ is the current default active
theme. It’s minimal, flexible, responsive, and
destined to be replaced by ‘Twenty Twenty’. Lastly, after configuring and customizing your site, you want to make sure that it’s
optimized and secure. These final steps are critical to running a healthy website, and
are covered in their own chapters later in the book. For now, let’s continue planning
with a quick look at the basic requirements.
Required time
WordPress claims a “famous 5-minute install” process, but there’s more to the story.
Before getting to the 5-minute installation, you need a domain name, web host (i.e.,
web server), and a database. With experience, these initial steps can go quicker, but
may require some quality time while learning the ropes.
If you’re new to WordPress, plan for a few hours to soak it all in, find good hosting,
register a domain name, configure the server, and set up the database. Then plan
for another hour to install, configure, and get to know WordPress. Again, with
For what it’s worth, it generally takes me about
experience it’s possible to streamline the process to require much less time. But
an hour to set up a fully configured, self-hosted it’s not a race. Take as much time as needed to understand your actions and make
WordPress site. From there, the amount of time the best decisions. By taking your time and doing it right, you establish a solid
spent customizing and adding plugins/themes
varies depending on the goals of the site.
foundation for creating and working with WordPress.
7
“Simplicity is the ultimate sophistication.”
— leonardo da vinci
Installation
Having met the requirements on our “pre-install” checklist from the previous
chapter, we’re now ready to install WordPress and watch the magic happen. For the
initiated, WordPress installation may be described simply as, “unzip/upload, edit
the wp-config.php file, and visit /wp-admin/install.php in your browser.” With
understanding and experience, installing WordPress can be that easy.
Yet, rather than end the chapter here, let’s walk through the installation process,1–2
explaining the details of each step. We’ll then take a tour of WordPress, go for a
quick test-drive, and look at some important administrative functionality. So now,
The Chinese word 和平 “Hépíng” represents for the moment you’ve been waiting for, it’s time to install WordPress.
tranquility, calmness, and peace.
Step 2. Connect to your server using your FTP program and upload the entire
WordPress directory to the web-accessible root directory of your site. This is
Some web hosts offer “one-click” installations typically named “httpdocs”, “htdocs”, “home”, or similar.
of WordPress. This can save time, but it’s also
beneficial to understand what is happening
behind the scenes. Ask your host for details. 1. WP Codex: Installing WordPress @ https://wp-tao.com/545
2. WP Codex: Installation Techniques @ https://wp-tao.com/583
9
The Tao of WordPress
Step 3. Open your browser and enter the following URL in the address bar:
https://example.com/wordpress/wp-admin/install.php (note: replace Note: If you do not specify
“wordpress” with the name chosen in Step 1, and replace “example.com” a password, one will be
generated for you and
with your domain name). displayed on the “Success”
page. If you do not specify a
Step 4. Now on the WordPress installation page, fill in the required fields with username, WordPress will use
your information. For the username, it’s good practice to choose something the default name, “admin”.
other than “admin” to help secure your site against automated attacks. Also
remember to choose a strong password.
Step 5. Once you’ve completed the fields, click “Install WordPress” to make it so.
After WordPress is installed, you’ll see a “Success” page that displays your
username along with a “Log In” button.
First let’s visit the public-facing side, or front-end of the site. An easy way to get
there is from the Toolbar at the top of any screen. Just hover over your site’s name
and click the link to “Visit Site”. When you visit the front-end, you’ll see the default
active theme, Twenty Nineteen. Take a few moments to surf around the front-end and To visit the front-end of your site, hover your
familiarize yourself with the theme’s appearance, features, and so forth. site’s name in the Toolbar and click “Visit Site”.
10
Installation : The Toolbar
Once you’ve seen the default theme, you may want to jump right in and begin
customizing. Before we get into themes, plugins, and the myriad ways to customize
WordPress, let’s return to the Admin Area and continue the tour.
The Toolbar
To return to the Admin Area from the public
An easy way to get to the Admin Area is via the Toolbar. As before, hover over your
side of your site, hover over your site’s name
and click “Dashboard” or other destination. site’s name and select your destination. The Toolbar makes it easy to jump back and
forth between the back-end and front-end of your site.
Note: The Toolbar is displayed Later in the book, we’ll learn how to customize the Toolbar with links and other
on the front-end only for users tools. For now, just know that it’s there to provide a more seamless experience with
who are logged-in to WP. Try
logging out and watch the WordPress, putting all the essentials within easy reach.
Toolbar disappear.
By default, the Toolbar is displayed across your entire site, on all pages on the
front-end and back-end. While there are plugins to disable the Toolbar site-wide,
WordPress itself only makes it possible to disable the Toolbar on the front-end. This
is done by visiting your Profile page in the Admin via Users > Your Profile, and then
unchecking the box to “Show Toolbar when viewing site”.
Main Menu
In the Admin Area on the left side of the screen is the WordPress main menu. The
main menu contains links to most of your site’s settings, plugins, themes, and
everything else. We’ll be going through the entire Admin Area in detail in the next
chapter. For now, take a quick jog through the menu items to see what’s available.
The main menu in the WordPress Admin Area Hint: to save screen space, you can click the “Collapse menu” button beneath the
provides links to just about everything. main menu, and then click again to restore the full-width menu.
11
“The object is not to make the tree
look like a bonsai, but to make the
bonsai look like a tree.”
— john naka
Configuration
At this point, having successfully installed WordPress, you are literally ready to rock.
In this chapter we’ll continue with a concise tour of the Admin Area, configuring
WordPress along the way. 99% of the configuration process is handled via the luxe
comfort of the Admin Area. The other 1% involves doing small tasks on the server.
Our configurational tour will coincide with the order in which settings and tools are
presented to users in the Admin Area. This will help to familiarize the reader with
WordPress, while configuring all available settings along the way. It’s a win-win.
“Configuration” is written as 組態 in
Traditional Chinese. Now you know.
As we get into configuring WordPress, we’ll see that the default WordPress
settings are optimal for most scenarios. In other cases, existing options may prove
insufficient for your specific needs. Whatever the case, we’ll optimize all settings
using the cleanest, most efficient methods possible. Along the way, we’ll see some
useful plugins and techniques to extend and enhance our WordPress-powered site.
Login screen
The Login screen is where registered users can log in to the Admin Area. It’s
available via either of these URLs:
• https://example.com/wordpress/wp-login.php
• https://example.com/wordpress/wp-admin/
For each of these URLs, replace “example.com” with your domain name, and
“wordpress” with the name of the installation directory. If WordPress is installed in
The WordPress login screen, where it all begins.
the root directory, the login page is located at https://example.com/wp-admin/.
13
The Tao of WordPress
Lost password
If any registered user (including the primary admin) forgets their password, a new
one may be requested by clicking “Lost your password?” from the Login screen. If
needed, the lost-password page is available at the following URL:
• https://example.com/wordpress/wp-login.php?action=lostpassword
As always, edit the URL with your specific domain and WP directory. For more ways
to change or reset your password with WordPress, check out DigWP. 1
By default, WordPress disables registration for your site. If you look at the
screenshots of the login and password pages, you’ll notice there is no link to
“Register” for the site. As we’ll see later on, you can enable user-registration at any
time by visiting Settings > General, and checking the box, “Anyone can register”. When
registration is enabled, the login and password screens will display a link to the
registration page. You may also access it directly via its URL:
• https://example.com/wordpress/wp-login.php?action=register
After a visitor registers with your site, they will be able to log in and customize
their profile and do whatever it is they are allowed to do, according to their default
User Role, which is set in the General > Settings as “New User Default Role”. For more
information, visit the Users section later in this chapter.
14
Configuration : Dashboard
Dashboard
The WordPress Dashboard is the first thing you’ll see when logging in to WordPress.
It displays a variety of default widgets for recent comments, news, and much more.
As explained in the previous chapter, Screen Options are available to customize key
pages in the Admin Area. With just a few clicks, you can optimize the Dashboard
with tools and resources to help streamline your administrative process.
Even better, it’s possible to create your own custom widgets for your WordPress
A few clicks later and the Dashboard is simple, site. You can include custom links, content — just about anything you can imagine.
refreshing, and ready for custom widgets.
Similar streamlining may be done using the Learn how in the Customize the Dashboard section of the Customization chapter.
Screen Options for many screens throughout
the Admin Area. 1. For example, the option to select single-column dashboard layout. For a fix see DigWP @ https://wp-tao.com/642
15
“It’s not that every snowflake is unique,
it’s that every everything is unique.”
— anonymous
Themes
If you’ve followed along with the book this far, your site is now ready for
customization via themes and plugins. In this chapter, the possibilities become
endless as we explore WordPress themes — what they are, how they work, where to
get them, and much more. In the next chapter, the path continues with plugins.
Unlike anything else, themes enable you to transform the appearance and
functionality of your entire site with a just a few clicks. Themes are the heart of
WordPress, enabling virtually anyone to create awesome websites. Whether you
want a simple blog or full-featured e-commerce site, themes can make it happen,
The Chinese characters 設計 mean to design,
usually for free, and with minimal effort. 1
layout, or plan.
There are literally thousands of WordPress themes available on the Web, and many
of them are freely available from the WP Themes Directory. 2 Outside the Themes
Directory, there are free themes, premium themes, and everything in between. To
navigate the endless ocean of themes, understanding and strategy are essential.
The Tao of WordPress theme is minimal,
responsive, and perfect for learning WordPress.
Log in to the Members Area for FREE download. 1. WP Codex guide to using themes @ https://wp-tao.com/88
2. The WordPress Themes Directory @ https://wp-tao.com/89
17
The Tao of WordPress
Endless possibilities
The good news is that there are themes for virtually every occasion, business,
portfolio, personality, and style imaginable, and many of them are free. The not
so good news is that some themes are, well, not so good. And finding the good
ones can be a tedious process. Fortunately, this chapter brings eight years’ worth
of WordPress experience to help you understand and find the perfect theme.
In general, the better the theme, the less code you have to touch. As we’ll see
later on, there are many ways to customize themes, such as the “Theme Options”
screen in the Admin Area, installing plugins, and editing code. Indeed, if you’re
comfortable with code, than any theme has the potential to be great. Or even
better, you can build your own theme to make everything exactly perfect.
Using this chapter as a guide, you’ll learn how themes work, how to customize
them, and how to find the perfect theme for your WordPress-powered site.
18
Themes : Brief history of themes
Since that time, WordPress themes have continued to multiply and evolve.
Better features. Responsiveness. Mobile themes. UX wizardry. In the premium
theme market, competition remains fierce. And that translates into better
themes and better deals for WordPress users. But navigating the vast ocean of
themes can be an overwhelming task, so let’s continue the journey with a look at
some of the themes that are immediately available to you.
19
“It’s supposed to be automatic,
but actually you have to push this button.”
— john brunner
Plugins
Plugins enable you to extend WordPress’ built-in functionality to do almost
anything. With just a few clicks, you can integrate shopping carts, social
networking, bulletin boards, member forums, custom content, advertising,
slideshows, and so much more. Seriously, these days WordPress users enjoy a
wealth of free, awesome plugins that can do just about anything imaginable.
In this chapter, we’ll learn how plugins work, what to look for in a good plugin,
where to find plugins, and everything in between. We’ll also see how to diagnose
The Chinese characters 延長 mean to and resolve potential issues, and how to test your plugins for proper functionality.
expand, extend, or develop. Along the way, we’ll mention some of the most useful plugins, and check out a list of
the most essential plugins for any WordPress site.
Overall, this chapter is straightforward: find, install, and use the best plugins to
extend WordPress to do amazing new things.
21
The Tao of WordPress
Akismet
Far and away, Akismet is one of the best anti-spam plugins available. Once activated, After activating Akismet, it will display a
notice at the top of the page, explaining that
you’re prompted for your “Akismet API key”, which is available by signing up at the
the plugin is active but not enabled until you
plugin’s website. After obtaining your key, visit the “Akismet Configuration” screen enter you “Akismet API Key”. To do so, visit the
to enter it and choose a couple of basic options. “Akismet Configuration” screen, as seen below.
Once enabled, Akismet runs silently behind the scenes, checking comments and
blocking spam. You can check the spam bin at any time by clicking the “Spam” link
on the Comments screen. Occasionally, Akismet will miss a spam comment, or a
legitimate comment will get flagged as spam. Periodically, you may want to scan
through the spam bin and rescue any false positives, or “ham”.
After it’s collected some data, Akismet displays your “ham-vs-spam” statistics on the
“Akismet Stats” screen, available from the Dashboard menu. There you will find lush
charts and graphs displaying your comment statistics every which way.
22
Plugins : Default WordPress plugins
Hello Dolly
Also included with WordPress, the Hello Dolly plugin is much simpler. After
activating the plugin, a random line from Louis Armstrong’s unforgettable song,
“Hello Dolly”, is displayed in the upper-right corner of every page in the Admin Area.
This plugin, as far as I can remember, has always been included with WordPress, so
it holds a special significance, and even more so for Jazz enthusiasts. In the words of
WordPress-founder, Matt Mullenweg:
Hello Dolly also serves as a good example of the potential simplicity and elegance of
plugins. The plugin consists of a single PHP file that contains less than 100 lines of
code. This simplicity provides an opportunity to learn and see how plugins work.
Take a moment to open the Hello Dolly file in your code editor. It’s located at
/wp-content/plugins/hello.php. Then edit some of the quotes beginning on
around line 18 with some of your own. Finally, upload the plugin file and visit the
Admin Area to see the results. The quotes are random, but at some point, you’ll see
your custom quotes displayed right there in the Admin Area.
While tinkering with the hello.php file, locate “font-size: 11px;” and change it
to “font-size: 24px;”. Then upload the file and revisit the Admin Area, where you
should see the quotes displayed in a larger font-size. This is an example of how it’s
possible to change the appearance of WordPress by using a plugin.
While many plugins consist of numerous files
and hundreds or thousands of lines of code,
‘Hello Dolly’ consists of a mere 80-ish lines. Feel free to experiment further with the hello.php script. Learn from it, memorize
Shown here is the entirety of the plugin’s a few classic Armstrong quotes, and then either delete it or leave it enabled to keep
source code. An excellent learning tool.
the dream alive.
23
“Risk comes from not knowing what you’re doing.”
— warren buffett
Tightening Security
If your site is on the Web, it’s going to be attacked. That’s the grim reality. And even
more disconcerting is the fact that, if your site is online, there is no such thing as
perfect, 100% security. Anyone who says otherwise is lying. It is possible, however,
to protect your site against a large percentage of attacks, especially the automated
ones, which are by far the most common.
Using malicious scripts, criminals can scan thousands of sites for vulnerabilities
in minutes. If you examine your server logs, you will see the patterns of automated
The characters 安全 represent security.
scanning, it happens constantly. Picture legions of hungry animals looking for their
next meal, with your site as an “all you can eat” buffet, and you’ve got the idea.
In this chapter, we employ strong measures to secure our site against automated
scanning, spamming, and hacking. By applying layers of security to our sites, we can
protect against automated attacks, malicious exploits, and other nefarious activity.
A key principle here is that the more layers applied to a site, the greater its security.
25
The Tao of WordPress
Even so, taking steps to secure your site — regardless of where it’s hosted — helps
to ensure its existence, integrity, and potential success. A secure site provides a safe
environment for visitors to make transactions, upload content, leave comments,
and interact in general. People and search engines tend to prefer sites that are safe
and secure. When a site gets hacked, Google displays a scary warning message that
drives your traffic elsewhere. Insecure sites risk their reputation and rank in the
search results. Security provides a solid foundation for a thriving, growing site.
From large corporate and e-commerce sites to small portfolio sites and blogs,
security is mission-critical. Taking the time to protect the integrity of your resources
is well-worth the effort. Every security technique that you apply to your site adds
another layer of protection against threats and exploits. And it all begins by staying
current with WordPress.
26
Tightening Security : WordPress is secure.
WordPress is secure.
With all of this talk about malicious code and hacked websites, its easy to have
some concerns. But don’t worry. The previous section is meant to shed light on
the importance of good security, which WordPress takes very seriously. When
discovered, serious vulnerabilities are immediately patched, and a new, more secure
version of WordPress is released.
This is why it’s so important to keep WordPress, themes and plugins updated to
their current versions. Doing so ensures that you have all the latest improvements,
security patches, and bug fixes. Indeed, staying current with WordPress is the first,
best thing you can do to keep your site secure.
This is why, throughout the book, it’s recommended that you choose officially
approved plugins and themes from WordPress.org. Themes and plugins not
approved by the WP team may or may not be safe, which is why it’s important to do
your research before installing something from, say, WP-Scorpion.biz.
While there are risks, most plugins by trusted authors are well-coded and perfectly
safe. The point here is that plugins and themes should be carefully scrutinized
before installation and activation.
27
“Let your performance do the thinking.”
— h. jackson brown, jr.
Optimizing Performance
Websites should be as fast as possible. When your pages load quickly, your
visitors are happy, and happy visitors are the best. How quickly your pages load
depends on many factors, including some things you have control over, and
some things you don’t. For example, if your pages are loading slowly because of
limited server resources, there are steps that can help. Conversely, if your pages
are slow because of the visitor’s internet connection, there’s not a lot you can do.
Optimization is all about improving those things that can be improved, such
The characters 性能 represent performance. that you’ve done your part to ensure that your pages load quickly — regardless
of external circumstances. Improving the performance of your site helps to:
Bottom line: fast sites succeed on the Web. And this chapter shows you how to
make your WordPress-powered site blazing fast. Of course, there isn’t a magic
plugin that will optimize everything. Rather, optimizing performance is like
optimizing security: it happens in layers. Each new technique that you apply
WP Codex guide to optimizing performance further improves the performance of your site. Some techniques provide bigger
@ https://wp-tao.com/213
payoffs than others, and some are more difficult than others to implement, but
the end result is that any optimization steps you’ve taken work cumulatively to
make your site better, faster, and more awesome.
29
The Tao of WordPress
Optimization overview
Before getting into the optimization techniques, let’s take a moment to consider
some of the broader aspects of site-optimization. For example, it’ important to have
an understanding of how your site is performing before it’s been optimized. Using
free online tools, it’s possible to check key aspects of site performance, such as load-
time, page-size, number of HTTP requests, and more to establish a baseline.
webpagetest.org – https://www.webpagetest.org/
Online tool for checking basic performance of web pages. Google’s PageSpeed is just plain awesome.
@ https://wp-tao.com/214
load impact – https://loadimpact.com/
Online tool that runs advanced load tests and more.
gtmetrix – https://gtmetrix.com/
Online tool that checks your site against both Google’s PageSpeed and
Yahoo’s YSlow performance recommendations.
pingdom – https://tools.pingdom.com/
Online tool that checks essential performance aspects of your site.
On their own, these tools can provide a LOT of information that can
Pingdom’s easy-to-use test results make it nice.
be overwhelming to the uninitiated. At first, focus on load-times and overall
@ https://tools.pingdom.com/
performance scores. Higher scores and lower load-times are the goal of this chapter.
As we go through the different techniques, the jargon and data presented for the
various online speed tests will begin to make sense.
30
Optimizing Performance : Optimization overview
Establish a baseline
To begin, test your site’s homepage using Google’s PageSpeed and see where it’s at
performance-wise. Use this score as a relative baseline for your site’s performance.
That way, as you implement optimization techniques, you can measure and
compare the results. After obtaining your baseline score, refresh the PageSpeed tool
and run the test again on Google’s own home page. The results of that test give us
something to aim for, as Google’s page performance is about as good as it gets.
Factors to consider
Google’s homepage @ https://google.com/ How you go about optimizing your site depends on numerous factors, such as
hosting, traffic, and the type and size of your site. Here is a quick overview:
hosting
The type of hosting you have determines the amount of control you have over the server.
Most of the optimization techniques and
recommendations are summarized neatly at For example, with shared hosting, the host manages the server, which means limited
the following two guides: control. Conversely, virtual/dedicated hosting provides control over most if not all
Google’s “PageSpeed Insights Rules” aspects of server configuration, providing much control over performance.
@ https://wp-tao.com/216
traffic
Yahoo’s “Exceptional Performance”
@ https://wp-tao.com/217 Traffic plays an important role in deciding how much optimization is necessary. For
example, small blogs with light traffic may be fine with existing performance levels,
whereas sites with heavier traffic will certainly want to boost performance. While
every site will benefit from better performance, in general, the extent of recommended
optimization is proportional to the site’s volume of traffic.
purpose
The type and size of your site should be kept in mind when optimizing your site. For
example, for large e-commerce sites, optimization is mission-critical. Likewise, sites
serving up lots of media content will benefit greatly from caching, and text-heavy sites
will benefit from compression. In general, most optimization techniques apply to every
site, but keeping the type of site in mind will help to make wise decisions.
31
“You have to learn the rules of the game.
And then you have to play better than anyone else.”
— albert einstein
Improving SEO
Ultimately, websites are for people. But people can only visit your site if they are
aware of its existence. The old saying, “build it and they will come” certainly applies
on the Web, but the amount and timing of traffic to your site depends on its online
visibility. The visibility of your site determines its success, and that’s what SEO is all
about: increasing the visibility and success of your website.
The Chinese character 勝 represents success SEO stands for “Search Engine Optimization”, but has evolved to represent much
or victory. May it be yours on the Web. more. Good SEO strives to optimize pages for both search engines and human
visitors. They are two sides of the same coin, each connected to the other. The more
that search engines like your content, the more it will be displayed in the search
results. In turn, the more that visitors like your content, the more it will be shared
around the Web via social media services, blog posts, and so on.
Going further, as search engines place more value on well-liked content, your pages
will continue to climb in the search results. The process is a self-perpetuating cycle
for sites that are well-optimized for search engines and people. In this chapter, we’ll
see how to optimize for both sides of the SEO coin.
33
The Tao of WordPress
So in this chapter on SEO, we’re going to keep it simple, efficient, and effective.
We’ll focus on the fundamentals, applying proven techniques and strategies to
improve the performance of our site with visitors, and with the search engines.
As with optimizing performance, the first thing we want to do for SEO is to see
where our site is at currently. A baseline for comparison purposes. Here are some
excellent free tools for checking the SEO of any site (some may require registration).
Seoptimer – Website review and SEO audit tool SiteCheckup – SEO made easy
@ https://www.seoptimer.com/ @ https://seositecheckup.com/
The Reaction Engine – Analyze the SEO for a given keyphrase Small SEO Tools – Nice collection of useful SEO tools
@ https://www.reactionengine.com/ @ https://smallseotools.com/
34
Improving SEO : First steps to better SEO
HubSpot – Generates marketing report for your pages Lipperhey – Analyzes the quality and ‘searchability’ of your site
@ https://website.grader.com/ @ https://www.lipperhey.com/
WebGnomes – Analyzes the SEO performance of your site UpCity – Analyze and compare site rank against competitors
@ https://wp-tao.com/617 @ https://wp-tao.com/618
WooRank – Website analysis with many great features Site Analyzer - Multi-criteria SEO analysis
@ https://www.woorank.com/ @ https://www.site-analyzer.com/
Once you begin checking your site using these tools, you’ll see that there are many,
many ways to optimize your site for the search engines. Before continuing, take a
few minutes to check your site using one of the free SEO tools. Without worrying
about every little detail, keep the general results in mind so you know what to look
for as we continue with improving our site’s SEO.
35
“Stop thinking in terms of limitations
and start thinking in terms of possibilities.”
— terry josephson
Customizing WordPress
The act of customizing something makes it uniquely yours. For example, back in
high school, I customized my jean jacket with patches, buttons, and artwork. If
someone else saw that jacket, they knew it was mine. Likewise with websites, you
want to customize it to suit your needs and represent what it’s all about.
With self-hosted WordPress, you literally have complete control over every aspect of
your site. If some aspect of WordPress’ default appearance or functionality needs
changed, it may be possible to do so via the settings in the Admin Area. If there are
no settings available that will make the desired changes, there may be a theme or
plugin that will do the job. And if all else fails, you have full control over the theme
C*U*S*T*O*M*I*Z*E
template itself, meaning you can make your site look and do whatever you want.
W*O*R*D*P*R*E*S*S
37
The Tao of WordPress
To put things into perspective, here is a general overview showing where to begin
with your customization efforts.
Admin Area & default Basic functionality such as enabling/disabling comments, the number Easiest.
WordPress settings of posts to display, enabling/disabling registration, implementing
permalinks, etc.
Install & configure Everything under the sun, but some niches/functionality are hit or Easy to Advanced
themes/plugins miss. Plus, some plugins may require advanced configuration. (usually easy)
Configure theme Colors, font-sizes, positioning of sidebars, header images, background Easy.
options/widgets images, menus, widgets, colors, fonts, and potentially much more,
depending on the theme.
Customize theme Page structure (HTML), appearance (CSS), behavior (JavaScript), and Medium/Advanced
template files dynamic functionality (PHP). Essentially, anything is possible via (varies with theme)
template customization.
Edit some WordPress Literally any aspect of WordPress. As a rule, you should never change Never do this.
core files.. any core files. People get mad.
Keep in mind that these methods aren’t always mutually exclusive. The more
customization that needs to be done, the more likely it is that you’ll be configuring
settings, installing plugins, and customizing your theme files to make it happen.
The take-home message here is that there are numerous points of entry for getting
in there and customizing WordPress.
38
Customizing WordPress : Stay on the path
With that in mind, let’s get into the different ways to customize WordPress. The
information contained in the next sections equip you with the knowledge needed
to implement just about any technique. We’ll then apply theses methods in the next
chapter with some popular and practical customization techniques.
For example, rather than hard-coding a shopping cart into your theme, using a good
e-commerce plugin means that somebody else has already done the work, so you can
get up and running in less time. Then, if later you decide that a shopping cart is not
39
“It is good to have an end to journey toward;
but it is the journey that matters, in the end.”
— ernest hemingway
Techniques
With a solid understanding of WordPress under the belt, it’s time to look at some
practical techniques for customizing your WordPress-powered site. There are
literally thousands of great customization techniques on the Web, but some are
more practical and popular than others. This chapter rounds up some of the most
frequently implemented modifications, plugins, tricks, and tips.
As you read through the chapter, each technique may or may not be useful for
you, however, following along will prove a useful exercise in furthering your
The Chinese characters 長壽 represent long understanding of how WordPress works. If anything, some of these techniques will
life, or longevity. May you have it abundance. spark new ideas for your own site. If you think of a technique that isn’t covered in
the book, search the Web to see if there are any good resources, tutorials, or plugins.
As we’ve seen, there’s a plugin for just about everything, and for everything else
there’s a custom function, plugin, or technique that will do the job. In most cases,
it’s just a matter of locating those who have “already been there and done that.”
Each of the techniques and plugins in this chapter includes a concise description
and walkthrough of the essential steps. Staying on the path of WordPress, each
technique strives to use existing functionality and as touch as little code as possible.
When modifications to the theme template or other files are required, remember to
make a backup copy before making any changes. Doing so makes it possible to “roll
back” to original condition should something go awry. Also, whenever possible, we’ll
refer to the Tao of WordPress theme to explain steps in the various techniques. 1
1. Log in to the Members Area to download the ‘Tao of WordPress’ theme (and child theme).
41
The Tao of WordPress
Make it easy for visitors to share your content by adding a set of “share” buttons on
your posts, pages, sidebar, and anywhere else. Here the best plugins that I’ve found
for doing so. They are all top rated and provide excellent features.
42
Techniques : Integrate social media
Twitter is the place to share your content in real-time, get instant feedback, and
connect with others. Integrating Twitter with your site involves techniques such as
auto-tweeting your posts, including tweets in post comments, and displaying your
recent tweets in the sidebar. To do so, here are three plugins worth checking out.
tweetily – https://wp-tao.com/405
Tweetily is a set-and-forget plugin that makes it easy to share all of your new posts with
your Twitter followers. Features include easy connection to your Twitter account, next-
tweet countdown, hashtag focusing, and much more.
Tweetily automatically tweets your new posts. twitter mentions as comments – https://wp-tao.com/406
This plugin “scours Twitter for people talking about your site and silently inserts their
Tweets alongside your existing comments.” Even cooler than that, tweets are handled
1. Social Media Plugins for WordPress like regular comments, so you can manage them from the Comments Screen. Too many
@ https://wp-tao.com/404 awesome features to name here, so definitely worth a look.
43
“Variety is the very spice of life,
that gives it all its flavor.”
— william cowper
Tips & Tricks
As a way of saying “thank you” to everyone who purchases The Tao of WordPress, here
is an exclusive bonus chapter with more useful tips and tricks for customizing your
WordPress-powered site. This chapter draws upon the principles and techniques
covered in previous chapters and applies them to the art of customizing WordPress
via theme templates, shortcodes, and jQuery. Using a minimal amount of code, it’s
possible to add new functionality and fine-tune the look and feel of your site.
1. Log in to the Members Area to download the ‘Tao of WordPress’ theme (and child theme).
45
The Tao of WordPress
Step 2: Copy the parent theme’s header.php file to the child theme.
Step 3: Add the following image markup just before the <hgroup> in the child
theme’s header.php file:
<img src="/wp-content/themes/wptao-child/img/wptao-logo.png"
class="header-logo" alt="">
Then change the value of the src attribute with the path to your image file,
and upload the modified header.php file to the server.
After completing step 4, the logo is displayed,
Step 4: Open the child theme’s style.css file and add the following lines of CSS: but it’s too close to the top of the page. So we
can add “margin-top: 10px;” (without the
body .header-logo { float: left; width: 150px; height: auto; } quotes) to the .header-logo class. After
body header#page-header hgroup { float: left; } doing so, the header looks like this:
body header#page-header nav { clear: both; }
After uploading the child style.css file to the server, revisit your site and refresh
the page to make sure the new style.css file is loaded by the browser. If all went
according to plan, your logo should be displayed to the left of your site’s title and
tagline. Note that it may be necessary to include some additional CSS rules to
position and style the image as desired. See the sidebar for a quick example.
46
Tips & Tricks : Customize featured images
Featured images are stored in the Media Library and sized according to the options
chosen in your Media Settings. There you may specify three sizes for each uploaded
image: thumbnail, medium, and large. Additional sizes may be specified by adding
the following snippet to the theme’s functions.php file:
This snippet defines the default size for post thumbnails, and then defines two more
custom sizes. You can define as many custom sizes as necessary with additional
instances of add_image_size(). You can then select and insert custom-size images
After applying a snippet of CSS, the featured
from the dropdown menu on the Insert Media screen.
images are floated left and given a healthy
right margin to keep things looking sharp.
47
Continue the journey…
Get the book @ https://wp-tao.com/