Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
WordPress 4.0 Site Blueprints (Second Edition)
WordPress 4.0 Site Blueprints (Second Edition)

WordPress 4.0 Site Blueprints (Second Edition): Create a variety of exciting sites for e-commerce, networking, video streaming, and more, using WordPress

eBook
$27.98 $39.99
Paperback
$48.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

WordPress 4.0 Site Blueprints (Second Edition)

Chapter 1. Migrating a Static Site to WordPress

Many people come to WordPress after some experience of creating static sites using HTML and CSS; in fact, this is what happened to me. I had been building static sites for a while and wanted to start developing with content management system (CMS), which would make it easy for me to import existing static sites and update them using the CMS interface.

The great news is that WordPress makes it possible for you to do this. In this chapter, you'll learn how to move your old site to WordPress as well as gain an understanding of how WordPress works and the benefits of using it. We'll cover these topics:

  • The difference between a WordPress site and a static site
  • How WordPress is structured and how it stores your site's content and design information
  • How to install WordPress on your server and set it up while keeping your old site live
  • How to choose and install a theme
  • How to add content to your new WordPress site, including importing content from your old site and adding new posts and pages
  • Installing plugins to add extra functionality
  • Launching your site once it is ready

So let's get started!

Note

In this book, you'll learn how to download and activate a theme that will give your site its styling and layout. If you want to learn how to take your static site and develop your own theme-based on the code in your HTML files, I recommend WordPress Theme Development Beginner's Guide, Packt Publishing.

WordPress versus static sites – the differences

If you've built static sites before, you'll know that they consist of a number of files that you upload to your server. These will include:

  • HTML files
  • One or more CSS files (referred to as style sheets)
  • Possibly JavaScript files if you're running sliders or other dynamic elements on your site

Your WordPress site will include different file types and it will also include a database, which is where your content will be stored.

The main elements of a WordPress site are:

  • The files running WordPress itself. These are mainly PHP files.
  • The files in your site's theme, including one CSS file (occasionally more) and a number of PHP files.
  • The files in any plugins you install. These will always include PHP files but may also include CSS and JavaScript files.
  • Files you upload to your site, including images and PDF files.
  • Your site's database, which will include a number of tables storing your content and site settings.

You'll learn more about these and what they do in the next section.

Understanding how WordPress stores content

Having read the list of files contained in a WordPress site, you may be feeling quite daunted! But the good news is that you don't need to think about the files I've listed here as WordPress does the thinking for you.

So, let's take a look at the contents of a WordPress site in more detail.

WordPress files

When you install WordPress, a number of files are uploaded to your server. The good news is that you don't need to do anything to these files; in fact, you shouldn't. If you edit these files (referred to as the core files), any changes you make will be lost when you install the next WordPress update.

Later in this chapter, you'll learn how to install WordPress. Once you've done that, you can ignore the core files. Phew!

Theme and plugin files and uploads

The next set of files is stored in the wp-content directory, inside your WordPress installation. This directory will normally look similar to this:

Theme and plugin files and uploads

Fig 1.1: The wp-content directory

Let's take a look at the file types:

  • themes: When you create your site, you will need to install a theme, which is what will give your site its design and layout and possibly, some extra features too, depending on the theme. There are thousands of themes available for you to download and use on your site, and a lot of them are free. WordPress stores the files for your theme in the themes folder, with each theme having its own folder. You'll never need to open these files or edit them.
  • plugins: These are extra packages you install in your site to add more functionality. There are thousands of plugins available, and like themes, a lot of them are free. Later in this chapter, you'll learn how to install and configure plugins on your site. Again, the good news is that you don't have to worry about these files; WordPress will do the work for you.
  • uploads: This folder contains all of the images and other media that you upload to your site. When you first install WordPress you might not have this folder yet, as it's automatically created the first time you upload media to your site. You don't actually upload these directly to this folder; instead, you use the WordPress interface to upload them and then WordPress stores them in the correct place for you. It is another example of WordPress making your life easier! Later in this chapter, you'll learn how to upload an image and insert it in a page on your site.

Sometimes, your wp-content directory will have some extra folders, for example, if a plugin adds one. Don't worry if that happens, just leave them alone!

Database

The final piece in the jigsaw is the database. This is where all of your content is stored—your posts, pages, and any settings you've made on your site.

The main benefit of using a database is that it keeps your content and your design separate. As your site grows, this makes your life much easier because you don't have to directly edit HTML files if you want to make changes to your site. The parts of each page that are the same across the site (for example, the header, footer, and sidebars) are kept separate from content, meaning if you want to change them you only have to do it once.

Everything you may need to do with your WordPress site can be done via the WordPress administration screens; you never need to touch the code. If you're not a techie, this will be a very good news!

Installing WordPress

Now that you understand how WordPress works, you're probably itching to get started! So, let's start by installing WordPress. There are two ways to do this:

  • Using an installer such as Softaculous or Fantastico, which may be provided by your hosting company
  • Directly installing WordPress using the Famous 5 Minute Install

Let's start with the easier way, which is to use an installer.

Installing WordPress using an installer

If your hosting provider gives you access to an installer, it will probably be accessible via your hosting dashboard or cPanel, which is a dashboard many hosting providers give you to manage your site.

Note

The exact way this looks and where you find it will vary from host to host, so your screen will probably look slightly different from what you see here, but the process is much the same.

My hosting provider includes a link in its control panel called Web Apps. Yours might be called Fantastico, Softaculous, or something else. If you're unsure, check with your hosting company and ask them if they provide a WordPress installer.

Installing WordPress using an installer

Fig 1.2: Accessing an installer

When I open this, I see a list of the web apps available to me, including WordPress:

Installing WordPress using an installer

Fig 1.3: Choosing WordPress in the installer

These are the steps you need to follow now:

  1. Click on WordPress and then on Install Now.
  2. You will be presented with a list of fields to complete. Fill them out as follows:
    • Prefix: I prefer to use just http:// as the www really isn't necessary these days.
    • Domain: This will already be filled out with your domain name; leave it as it is.
    • Directory: If you add something here, WordPress will be installed in a subdirectory of your site and not in your root directory. If you already have a static site running on this domain, using a subdirectory will mean that your static site will still work while you install and set up WordPress. If not, it's easier to leave this empty. You'll learn later in this chapter how to manage your old site while you're setting up WordPress.
    • Database Name: You can leave this as it is or change it to something that's more memorable to you. If you're not going to be working on your database, just leave it alone.
    • Table Prefix: Leave this as wp_.
    • Site Name: This is where you enter your site's title.
    • Site Description: This is where you enter your description or strapline. Most themes will display this below the title at the top of your pages. If you don't have a description, leave this blank.
    • Enable Multisite: If this is offered by your installer, leave it unchecked.
    • Admin Username: The default is admin, but for security reasons, you should change this to something unique and memorable for you.
    • Admin Password: Enter your password twice for logging in to your site. Be sure to make it secure, including uppercase letters, numbers, and other characters.
    • Admin Email: Enter your e-mail address.
    • Select Language: If this is an option, select your language if it isn't English.
    • Select Plugins: This isn't offered by all installers, so you may not see it. I leave this blank, preferring to install plugins later on.
    • Email recipient: If you add your e-mail address here, you will receive an e-mail with details of your new WordPress installation, including a link to the admin screens.

Tip

Some installers offer a backup option, which is a good idea to select if available. It's also a good idea to use a backup plugin in your site too. For a review of some of the best backup plugins, visit http://premium.wpmudev.org/blog/premium-freemium-wordpress-backup-plugins/.

Here, you can see an example for the installation I'm setting up:

Installing WordPress using an installer

Fig 1.4: Enter your site details

Once you've entered your details, click on Install and the installer will do its work. You will see a screen with a link to your new site and to the admin screens. Well done!

But what do you do if your hosting provider doesn't give you access to an installer? That's where manual installation comes in.

Installing WordPress manually

Installing WordPress manually takes a little longer, but isn't difficult as long as you know the steps to take. You'll need to learn how to do this if your hosting company doesn't provide an installer or if you want to install WordPress locally on your PC or Mac. This can be useful for working on a development site, where you're creating a dummy version of the site before you launch it to the world.

Note

If you want to install WordPress on your local machine, the process is very similar to the one here, but you'll also need to install an app such as MAMP (for Mac and Windows) or XAMPP (for Mac, Windows, or Linux). You can find instructions at http://codex.wordpress.org/Installing_WordPress_Locally_on_Your_Mac_With_MAMP and http://premium.wpmudev.org/blog/how-to-install-wordpress-locally-for-pcwindows-with-xampp/. For a guide to migrating your site to the live site once you're happy with it, refer to http://code.tutsplus.com/tutorials/migrating-a-wordpress-site-from-a-local-server-to-production--wp-26.

Installing WordPress manually consists of four steps:

  • Downloading the WordPress files
  • Creating a database on your web server
  • Uploading the WordPress files to your server
  • Running the WordPress installation script by accessing the URL for your site in your browser

Let's work through each of those steps in turn.

Downloading the WordPress files

To download the WordPress files, follow these steps:

  1. Go to https://wordpress.org/download/ and click on the Download button to download the files.
  2. This will download a .zip file to your computer. Unzip this.

Creating a database on your server using phpMyAdmin

Your site will need a database to hold all of your content. WordPress doesn't create this for you; you'll have to do it yourself.

  1. In your hosting provider's dashboard or in cPanel, go to phpMyAdmin. If you can't find this, ask your hosting provider; they might have a different way to create a database, such as using a wizard.
    Creating a database on your server using phpMyAdmin

    Fig 1.5: The phpMyAdmin home screen

  2. Click on the Databases tab.
  3. You will see a field labeled Create a new database. Type the name of your database in this field. Make a note of this as you'll need it again later.
  4. Click on OK.

You now have an empty database set up. The next step is to upload WordPress.

Note

Some hosting providers don't let you create databases in phpMyAdmin; you have to do it in your hosting dashboard instead. If this is the case, follow the instructions given by your hosting provider.

Uploading WordPress to your server

To upload WordPress, you'll need an FTP client or a code editing program with FTP built in. I tend to use Coda (http://panic.com/coda/), which is a code editor for the Mac, or FileZilla (https://filezilla-project.org), which is a free FTP client.

  1. In your FTP client or code editor, display your Downloads folder locally and the files on your remote server.
  2. If you already have a static site on your server and want to keep it running while you create your new site, create a folder inside your public_html folder. I'm creating a folder called blueprints1, as you can see in the following screenshot. If you don't have an existing site, you can skip this step.
    Uploading WordPress to your server

    Fig 1.6: The blueprints1 folder

  3. Now copy the contents of the wordpress folder from your Downloads folder to the folder you've created. If you haven't created a folder, copy it to the public_html folder. Don't copy the wordpress folder, copy its contents.
  4. Make yourself a coffee while you wait for the files to upload!

Now that you have a database and the WordPress files uploaded, you just need to activate the WordPress installation script by visiting your new site's URL in your browser.

Activating the WordPress installation script

To activate the installation script, you'll need to perform the following steps in your browser:

  1. In your browser of choice, type in the URL for your new site. Remember that if you've created a folder for your site, it will be http://yourdomain.com/folder, where folder is the name of your new folder and yourdomain.com is your domain name.
  2. You will be presented with the first of the installation screens, where you choose your language. Select your language and click on Continue.
  3. The next screen tells you what's coming up. Give it a quick read (and don't worry!) and click on Let's go!.
  4. The following screen is where you need to give WordPress some information about your database so that it can access it. Input the following:
    • Database Name: Enter the name you gave your database earlier
    • User Name: Enter the username you created for your database earlier
    • Password: Enter the password you assigned to your new username
    • Database Host: Leave this as localhost (unless your hosting provider uses a different hostname)
    • Table Prefix: Leave this as wp_

    You can see what I've entered in the following screenshot:

    Activating the WordPress installation script

    Fig 1.7: Entering your database details to install WordPress

  5. You'll now see a screen congratulating you on getting this far. Click on the Run the install button to continue.
  6. You're nearly there! All that's left is to enter your site details on the next screen:
    • Site Title: Enter the name of your site.
    • Username: Enter your username for logging in to your site (which is different form your database username—don't use the same username as this will make your site less secure).
    • Password twice: Enter the password you want to use to log in.
    • Your Email: Enter your e-mail address for notifications.
    • Privacy: Uncheck this for now as this is a development site and you don't want search engines finding it just yet. Don't forget to go back and check the box when you launch the site, otherwise you won't get picked up by Google.

    Here's what I've added:

    Activating the WordPress installation script

    Fig 1.8: Entering information about your site

  7. Next, you'll see the success screen. Click on the Log in button to access your new site.
  8. Now simply log in with your username and password and you'll be able to start administering your site.

The WordPress Dashboard and administration screens

Now that you've installed WordPress (whichever method you used) and logged in, you'll see the Dashboard screen. If you can see this screen, you've done everything correctly. Well done!

The WordPress Dashboard and administration screens

Fig 1.9: The main Dashboard screen in WordPress

But before you start configuring your site and adding content to it, let's take a moment to look at how this affects your old site.

Keeping your old site live while setting WordPress up

In the previous section, I mentioned installing WordPress in a subdirectory if you have an existing static site that you want to keep live while you create your new one.

Let's look at how this works:

  1. You install WordPress in a subdirectory, which has a different name from any of the pages in your site (if you have an HTML file with the same name as your subdirectory, the browser might go to the WordPress installation instead of that HTML page when a link to it is clicked).
  2. You uncheck the box, allowing search engines to index your site so that people won't stumble upon it when it's not ready. If you missed this step, you can make the change in the WordPress admin. Simply go to Settings | Reading and click on the Search Engine Visibility checkbox. Then, click on Save Changes. While WordPress does give you a warning that this is up to the search engines, in my experience, they do honor this and your site won't get found.
    Keeping your old site live while setting WordPress up

    Fig 1.10: The Reading Settings screen

  3. Once your new site is ready, you don't need to move it to the root directory; you just make a couple of small edits to the files and settings, and this tells WordPress that the site is in a subdirectory. We'll look at this later on in the chapter once your site is set up.

Installing a theme

Congratulations, you've now got a working WordPress site! It comes with the default theme bundled, which, at the time of writing this book, is Twenty Fifteen. While this is a good theme, you probably want to give your site a more bespoke design, so the next step is to find and install a suitable theme from the WordPress theme repository.

Introducing the WordPress theme repository

The WordPress theme repository, at https://wordpress.org/themes/, contains thousands of themes that you can download for free and use on your site. They vary hugely in terms of their design and the kind of sites they're suited to, but there's a good chance that there'll be one that works for you.

To install a theme, you don't have to go to the WordPress site and manually download it; instead, you can use the theme's screen in your WordPress admin, which you'll learn next.

Choosing a theme

With so many themes to choose from, where do you start? The first thing is to identify a set of keywords to use for searching that may include one or more of the following:

  • Colors
  • Layout details such as fixed, fluid, responsive, or the number of columns
  • Features such as accessibility or featured images
  • A subject (the type of site you're running)

Let's try finding a theme by following these steps:

  1. Go to Appearance | Themes and then click on the Add New button. This will open the theme repository in your admin screen.
  2. Click on the Feature Filter button. This will give you a screen full of checkboxes that you can tick to select keywords and filter the themes you can choose from.
  3. If you want your new site to look as similar as possible to your old one, or you have brand colors that you need to use, it makes sense to use Colors and Layout keywords. Add others as needed to filter down the list of themes.
  4. Once you've ticked all the checkboxes you want, scroll back up and click on Apply Filters. WordPress will then display the themes that have your keywords applied to them:
    Choosing a theme

    Fig 1.11: A filtered list of themes

  5. Scroll down the themes on display and choose the one that you like the look of. Hover over it with your mouse and click on Preview to have a look at it or Install to install it. Installing it won't do any harm; if you don't like it, you can always uninstall it afterwards.
  6. Once you've installed your theme, you'll see a screen telling you that it's successfully installed. It still isn't running on your site yet; to make this happen, click on the Activate link.

Next, we'll learn how to customize a theme for our own needs and change its settings.

Customizing your theme using the theme customizer

The theme customizer is a great WordPress feature that lets you make tweaks to a theme and see what difference they make without saving your changes, so it won't be visible to anyone visiting your site until you're ready.

Different themes offer different customization options, which vary from just editing the title and description to more comprehensive options such as customizing colors and layout. You can also edit widgets from the customizer.

I'm going to use a theme called Pinboard, which is responsive for mobile devices and offers the option to customize colors and the header and background image. This means I can create a bespoke site meeting my needs.

To install the theme and customize it, follow these steps:

  1. Click on Appearance to go to the Themes screen and click on Add New.
  2. In the Search themes... box, type Pinboard and hit the Enter key.
  3. WordPress will display the Pinboard theme for you. Hover over it with your mouse and click on the Install button.
  4. When you see the installation success screen, click on Activate.
  5. Next, in the Themes screen (click on Appearance if it isn't already open), click on the Customize button for the Pinboard theme.
  6. This will open the theme customizer:
    Customizing your theme using the theme customizer

    Fig 1.12: The theme customizer

  7. Start by editing the background image. Click on the Background Image link to the left. To remove the wood graphic, click on the Remove button.
  8. Click on the Colors link on the left and select Background color. Choose a color using the color picker. I'm choosing white, which will look quite nondescript for now, but will be better once I've made some other changes. Note that you can click on a color or type in the hexadecimal code.
  9. Finally, click on the Save & Publish button to save your changes.

Note

Hexadecimal codes are codes made up of six letters and numbers which tell a browser what color an element is. They are always preceded by a # and are used in HTML and CSS files to define the color of backgrounds, text, and more. For more on hexadecimal codes, visit http://en.wikipedia.org/wiki/Web_colors.

We're not going to edit any more using the theme customizer because this theme has extensive options screens, which let us do more. Some themes have more options in the theme customizer and don't use separate options screens; it all depends on the way the theme has been designed.

Tip

Important: If you want to edit your theme's code, do this using a code editor. Never use the editor that you can access via Appearance | Editor. Using this means, you can't undo your changes and could break your site. So, avoid!

Let's take a quick look at how the site is looking with this theme. To view your site, click on the link in the admin bar at the top of the screen with the title of your site; in my case, it's WordPress Blueprints.

Here's the site:

Customizing your theme using the theme customizer

Fig 1.13: The site with the Pinboard theme activated

Customizing your theme via the Themes options screens

This theme has multiple options screens, which we can use to make more changes. Not all themes will have these; it depends on the features that the developer has added.

Customizing colors

Let's make some changes in colors by following these steps:

  1. Go back to the admin screens by clicking on your site's name in the admin bar again.
  2. Click on Appearance | Theme Options to open the theme options screens.
  3. Click on the Design tab. You'll be presented with a range of color pickers to help you define the colors in your site; either pick a color or input the hexadecimal code for your color.
  4. Tweak some of the colors, trying to stick to a palette of colors that work well together. I'm using a palette of blues.
  5. Click on the Save Settings button and view your site. Here's how mine looks:
    Customizing colors

    Fig 1.14: The site with colors adjusted

  6. Repeat steps 3 to 5 until you're happy with your color scheme.

Customizing fonts

One of my favorite features of this theme is the fact that you can customize not just colors, but fonts too, a feature which not many themes have. So let's do this by following these steps:

  1. Go to Appearance | Theme Options and click on the Typography tab.
  2. There are three dropdown lists for fonts—Default Font Family, Headings Font family, and Body Copy Font Family.
  3. Select a font you like for each. I recommend sticking to a simple, legible font for body copy, and making the heading font more interesting.
  4. Scroll down to the Font Sizes options and make any changes you need for your design. Here, you can copy the font sizing that you used on your old site, if you want a similar look and feel.
  5. Next, scroll down to the Colors options and make changes to the text colors. I'm making some changes to tie in with the changes I already made to the background colors.
  6. Click on the Save Settings button and view your site. Here's how mine looks:
    Customizing fonts

    Fig 1.15: The site with font changes applied

  7. Repeat steps 2 to 6 until you're happy.

Tip

If you've been making lots of changes quickly, you might find that they don't all show up. If things aren't working as you expect, just save your changes and refresh the screen.

I'm just going to leave it at this for now, but if you want, you can explore all of the Themes options screens and make more changes. Now that we've done some work on the design, it's time to tweak your site's settings.

Adjusting your site's settings

Before adding content, you'll need to adjust some site settings for comments, reading, and permalinks. Follow these steps:

  1. Go to Settings | Discussion. Make adjustments to the discussion settings according to your site's needs. You may or may not want to allow comments. If you do this now, it will apply to all the new posts and pages you add, and that is why it's a good idea to do it early.
  2. Click on the Save Changes button.
  3. Go to Settings | Permalinks. The default setting for Permalinks gives your site the URLs, which aren't very friendly to search engines or human beings. Select another option depending on how your site will be structured. For a site consisting of mainly static pages, I would use the Post name option as it's good for SEO.
  4. Click on Save Changes. You'll now find that if you visit a page on your site, the URL is much more sensible.

    Note

    If you're using WordPress Version 4.2 or later, the so-called "pretty permalinks" will be set up as the default, so you may be able to skip this step.

  5. Go to Settings | Reading. Here you can select whether your home page will be a static page or a list of your latest blog posts:
    • To use a static page, select the A static page radio button and then select the page you want to use. If you also want to display posts in a blog page elsewhere, you'll need to create an empty page for that and select it in the Posts page drop-down box. Note that you may need to come back to this once you've created your home page.
    • To use a list of your latest posts, click on the Your latest posts radio button. How these are displayed on your home page will depend on your theme.
  6. Click on the Save Changes button to save your changes.

Adding content to your site

If you're migrating from a static site, you may well have content from that to import to your new site. Or you may have been running a blog or site on another platform whose content you want to import.

Before we can start importing content, you need to know what kinds of content WordPress uses.

Types of content in WordPress

WordPress uses three main content types:

  • Posts: These are your blog posts or news articles, which you add regularly. You can access them via the Posts admin menu.
  • Pages: These are static pages such as your content page and "about us" page. Your home page could either be a static page or a page listing all of your latest posts (we'll see how to set that up later on).
  • Attachments: These are images, PDFs, and other media, stored in the uploads folder, which we looked at earlier. Each of them also has an entry in the database, giving WordPress metadata about them. You access these via the Media menu or by uploading them to your page or post content.

You can also add your own content types using Custom Post Types, but we don't need to worry about that in this chapter.

There are three ways of importing content:

  • Using the importer tool
  • By copying text from your old site
  • By copying code from your old site

Let's start with the importer. This won't help you if your old site was built on HTML alone, but will be useful if you were using another CMS or blogging platform.

Importing content with the importer tool

The importer tool automatically imports content from a range of other services. Perform the following steps:

  1. Go to Tools | Import.
  2. Click on the name of the platform you were using for your old blog.
  3. WordPress will take you to an installation screen for the plugin, which imports content form that platform. Click on the Install Now button.
  4. On the successful installation screen, click on the Activate Plugin & Run Importer link.
  5. Follow the instructions onscreen. Depending on the platform you're importing from, you may have to upload an xml file or sign in to your account on the other platform. There will be multiple screens and you may have the option to import images as well as text.
  6. Once you've finished, click on Posts in the admin menu to see what posts have been imported. Your old site's content should have been imported to your new site, saving you a lot of work.

Importing content manually

There are two ways to do this—you can copy the text or the code. Copying the text will be easier if you're not used to working with code, but it may be less reliable.

Copying text from your old site

Let's have a go at copying the text from your old site by importing the text first. Follow these steps:

  1. First, create a new page or post. If your old site was a small static one, you probably only have pages to copy. Click on Pages | Add New to see the page editing screen:
    Copying text from your old site

    Fig 1.16: The Page editing screen

  2. Open your old site in another browser window and open the page you want to copy.
  3. Copy the old page's title and type it into the box that says Enter Title here.
  4. Now, copy the page's content and paste it onto the main page editing pane below the title.
  5. Check how it looks. If the layout and styling is a bit of a mess, you might need to start again, copying the code instead.
  6. Delete any images. You'll need to upload those to WordPress separately as any images that have copied across will be linking to the image files stored in the old site, which will disappear when you eventually remove that site.
  7. Click on the Publish button to save your new page.
  8. Repeat this for the other pages in your site.

Copying code from your old site

The page editing screen gives you the option to edit the HTML in the page; this means that you can paste HTML from your old site into your new pages by following these steps:

  1. Click on Pages | Add New to create your new page if you haven't done so already.
  2. Type the page title into the title box at the top of the screen.
  3. Above the content pane, click on the Text tab on the right-hand side.
  4. Open the HTML file for the page you want to copy from your old site. Find the HTML for the content and copy it. Don't copy the HTML for the header, sidebar, footer, or page title, or anything from the <head> section of the page. You will probably be copying a lot of text within <p> tags and a few other tags such as <ul> and <img>.
  5. Paste this code into the content pane in WordPress.
  6. Click on the Visual tab to return to the visual editor and see the results of what you've done.
  7. Delete any images; you'll need to upload these manually.
  8. Tidy up any formatting. You might need to switch between the Visual and Text tabs if there's any code causing problems. Do this with caution!
  9. Click on the Publish button to save your new page.
  10. Repeat this for the other pages in your site.

Creating new pages and posts

Once you've imported the content from your old site (or if you don't want to do that), you can start creating new pages and posts. To create new pages, simply follow the steps described for copying text from your old site in the preceding section, but instead of copying in the text, type it in manually.

To create a new post, follow these steps:

  1. Click on Posts | Add New.
  2. Type your post's title in the title box and the content in the text editing pane below. Use the formatting toolbar to change styles if needs be.

    Note

    The formatting toolbar gives you the option to change fonts and colors, but I would strongly advise not to do this. Use the styles provided with your theme and tweak fonts and colors using the Themes options screens. This will retain a professional, coherent look to your site.

  3. When you're ready, click on the Publish button to save your post.
  4. If you want to, assign one or more categories or tags to your post by selecting them from the list on the right-hand side or typing in new ones.
  5. Keep on doing this. If you want to add a back catalogue of posts, you can amend the publish date for each post in the Publish pane by clicking on Publish immediately and selecting the date you want to use. This will make your blog look more established than it would if all your posts had today's date!

Uploading images and media

The easiest way to add images and other media is to add them inside your posts or pages. Let's start with images.

Adding images to your posts and pages

WordPress lets you insert images anywhere you want in your post or page content by performing these steps:

  1. Open the post or page you want to add an image to and click on the point in the text where you want the image to appear.
  2. Click on the Add Media tab to open the media upload screen.
  3. Click on Select Files and select the image file you want to upload.
  4. The file will be imported and you'll see it on the screen. Now, work your way through the options on the right-hand side of the screen:
    • Title: This is the name of the image. Leave this as it is or change it to something more meaningful for accessibility and SEO so that it can help when searching media on your site.
    • Caption: Type the caption text here or leave it blank.
    • Alt text: Type in the alternative text for screen readers.
    • Description: Adding a description can help with SEO. It won't be displayed on the page, but may show up in search results.
    • Alignment: Select how you want to the image to be aligned. If you choose Left or Right, the text will wrap around the image.
    • Link To: Specify if you want visitors to be able to click on the image and go to its file or attachment page, to a custom URL, or if you want no link at all.
    • Size: Select from the default sizes WordPress gives you to choose how big this will appear on the screen.
  5. Click on Insert into page to insert the image.
  6. Your image will now appear in the editing screen, but it might not look very good because your theme's formatting isn't applied in the admin screens. To check how it looks, either click on the Preview button to preview without publishing your changes or click on the Update button to save your changes and then click on View page at the top of the screen. Here's my page with an image added:
    Adding images to your posts and pages

    Fig 1.17: The page with a right-aligned image of me!

Adding PDF files to your posts and pages

Adding PDF files is similar to adding images, with some minor differences. Perform these steps:

  1. Open your post or page and click on the point in the text where you want the PDF to appear.
  2. Click on the Add Media button and then Select Files.
  3. Select the file you want to upload. WordPress will upload it and display an icon for it on the screen:
    Adding PDF files to your posts and pages

    Fig 1.18: The Insert Media screen

  4. Complete the options on the right-hand side:
    • URL: Leave this as it is.
    • Title: This is the text that people will click on to download the file. Change this to something that makes sense for visitors.
    • Caption: Leave this blank.
    • Description: Add something here for SEO if you wish.
    • Link To: Choose whether to link to the file itself (my preference) or to an attachment page with the media file in it. I don't like this as it makes the visitor click too many times.
  5. Click on Insert into page.

To test what you've done, click on the Update button and then the View page link. My page now has a clickable link to a file:

Adding PDF files to your posts and pages

Fig 1.19: My page with an image and a media file

Now, you can repeat this with all of the images and files you want to add to your site.

Note

WordPress also supports video uploads and streaming videos from other sites. You'll learn about this in Chapter 5, Creating a Video Streaming Site.

Setting up navigation menus and widgets

Most themes support navigation menus that you can edit using the WordPress admin screens. This is much easier than coding your menus. They will also support widgets, which are items you can add to widget areas (normally in the footer and sidebar) to display lists of posts, links to other sites, social media feeds and links, and much more.

Let's start by setting up the navigation menu.

Creating the main navigation menu

You can use the Menus screen to create one or more navigation menus; sometimes, you might want to add extra smaller menus to your footer, for example, to display links to the popular content. But here, we'll create the main navigation menu by performing these steps:

  1. Go to Appearance | Menus.
  2. Depending on how your theme is set up, you may see a dummy menu displayed with your pages. To create a menu from it, click on Create Menu.
  3. Click on the Primary Menu checkbox below the menu. This will add it to the site's main navigation area.
  4. Click on the Save Menu button.
  5. Now go back to your site's frontend to view your menu:
    Creating the main navigation menu

    Fig 1.20: The site with a navigation menu

  6. Go back to the Menus screen to make adjustments to your menu if you need to. You can drag additional posts, pages, and categories (if you've created categories for your posts) on to it.
  7. Every time you make changes, remember to click on the Save Menu button. WordPress doesn't save changes to the menu in the background.

Adding widgets

Now let's add some widgets. Each theme will have different widget areas, which is where you place your widgets. Normally, you'll find widget areas in the sidebar and footer, but this theme has extra ones, giving more flexibility. Perform these steps:

  1. Go to Appearance | Widgets.
  2. By default, WordPress places a set of widgets in the theme's first widget area. In this theme, the first widget area is in the header, and those widgets look a bit odd there. Remove all of them except the Search widget by clicking on the arrow to the right of its box and clicking on Delete.
  3. Now, drag some widgets into the other widget area, putting them where you think they are appropriate. Think about mirroring the content in your old site where possible. If you want to just insert some text or HTML, you can do this using the Text widget. You can add more than one widget to each widget area, but don't go too mad!

Here are my widgets displayed in the Widgets screen:

Adding widgets

Fig 1.21: The populated Widgets screen

Here they are on my site's home page:

Adding widgets

Fig 1.22: The home screen with widgets

Installing plugins

Plugins can do just about any job you can think of, but some of the most common are:

  • Widgets to put in your sidebar or footer
  • Shortcodes that let you add code into your page without actually writing the code
  • Image galleries and slideshows
  • Links to external sites, such as social media feeds
  • SEO plugins to help you get found by search engines
  • Forms plugins to help your visitors get in touch with you
  • Performance plugins that will make your site run faster

Let's install a popular SEO plugin called WordPress SEO by Yoast:

  1. Go to Plugins | Add New.
  2. In the Search plugins... box, type WordPress SEO and hit the Enter key.
  3. WordPress will display a list of plugins, meeting your search criteria. Find the plugin called WordPress SEO by Yoast and click on the Install Now button.
  4. When asked whether you're sure you want to install the plugin, click on OK.
  5. When you see the success screen, click on the Activate link.
  6. The plugin is now installed and activated on your site.

I'm not going to show you how to configure the plugin as that's outside the scope of this book, but you will find guidance on the plugin website at https://yoast.com/wordpress/plugins/seo/.

Now try installing some more plugins according to your site's needs. We'll be working with lots of plugins in the other chapters of this book, so you'll get to try plenty of them out.

Making your WordPress site live

Once you have all your content in place, have installed and configured any plugins you want to use, and are happy with your widgets and with any customizations you've made to the design, it's time to go live.

If you aren't running your old site on the server still and didn't install WordPress in a subdirectory, this is very simple. Perform these steps:

  1. Go to Settings | Reading.
  2. Uncheck the Search Engine Visibility checkbox.

That's it! Search engines can now find your site. You'll need to do a bit more to publicize it, but it's now public. Enjoy!

However, if you still have your static site running, there's a bit more to do:

  1. In your FTP client or in File Manager in cPanel, find the folder where the WordPress files are located and find two files—index.php and .htaccess. If you haven't made any changes to permalinks, you won't have an .htaccess file, so just work with index.php.
  2. Copy the two files (or one if you don't have .htaccess) to the next directory up, that is, public_html.
  3. Open the copy in public_html and find the line that reads as follows:
    require ('./wp-blog-header.php')
  4. Change it to this:
    require ('./XXX/wp-blog-header.php'),

    Here, XXX is the name of your subdirectory.

  5. Save the file.
  6. Back in the WordPress admin, go to Settings | General.
  7. Edit the Site Address and WordPress Address fields so that they read as follows, where site.com is your domain and folder is the name of your subfolder where WordPress is stored. Change them to the following, making sure you spell everything correctly to avoid redirect loops:
    • WordPress address (URL): http://site.com/folder
    • Site Address (URL): http://site.com
  8. Click on the Save Changes button.
  9. Back in your FTP client, delete all the files from your static site. If you want to back them up, copy them to your PC, but make sure they're all gone from your server to avoid any conflicts.
  10. Now visit your site. You'll find that it uses your main domain name and not the subdirectory.

Summary

WordPress makes it easy for you to create a site that you can update and add to over time, letting you add posts, pages, and more without having to write code. In this chapter, you learned how to migrate your old static site into WordPress. You also learned how WordPress stores content, and how to install WordPress and import the content from your old site. You then configured your site, adding a theme, and menus, widgets, and plugins.

In the next chapter, you'll learn to create a social media site from scratch. So let's take a look!

Left arrow icon Right arrow icon

Description

WordPress is the world’s most popular Content Management System (CMS) and you can use it to create any kind of site you or your clients need. Using free plugins and themes for WordPress, you can create a store, a social media site, a review site, a video site, a network of sites or a community site, and more. Wordpress makes your job of creating your own website simple and hassle-free! If you’ve started using WordPress to create a blog or simple website, you’ll have had a taste of the opportunities offered by this massively popular CMS. This book will take you through the process of creating ten popular kinds of site using WordPress with free plugins and themes, each chapter covering various functionality of the web. After having learned how to migrate from your static site to Wordpress in the first chapter, you will then explore the world of social networking websites followed focusing on e-commerce. Without writing too much code, you’ll be able to create a store, a video streaming site, a team communications site, a jobs board, and more. This book is a one-stop solution to resolve all your worries about creating a website that will give the best experience to your users.
Estimated delivery fee Deliver to United States

Economy delivery 10 - 13 business days

Free $6.95

Premium delivery 6 - 9 business days

$21.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 23, 2015
Length: 324 pages
Edition : 1st
Language : English
ISBN-13 : 9781784397968
Vendor :
WordPress Foundation
Concepts :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Estimated delivery fee Deliver to United States

Economy delivery 10 - 13 business days

Free $6.95

Premium delivery 6 - 9 business days

$21.95
(Includes tracking information)

Product Details

Publication date : Sep 23, 2015
Length: 324 pages
Edition : 1st
Language : English
ISBN-13 : 9781784397968
Vendor :
WordPress Foundation
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 153.97
WordPress Search Engine Optimization- Second Edition
$49.99
WordPress 4.0 Site Blueprints (Second Edition)
$48.99
WordPress Web Application Development - Second Edition
$54.99
Total $ 153.97 Stars icon

Table of Contents

11 Chapters
1. Migrating a Static Site to WordPress Chevron down icon Chevron up icon
2. Creating a Social Media Site Chevron down icon Chevron up icon
3. Creating a Network of Sites Chevron down icon Chevron up icon
4. Creating an E-commerce Site Chevron down icon Chevron up icon
5. Creating a Video Streaming Site Chevron down icon Chevron up icon
6. Creating a Review Site Chevron down icon Chevron up icon
7. Creating a Jobs Board Chevron down icon Chevron up icon
8. Creating a Team Communications Site Chevron down icon Chevron up icon
9. Creating a Gallery Site Chevron down icon Chevron up icon
10. Creating a Membership Site Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5
(4 Ratings)
5 star 50%
4 star 50%
3 star 0%
2 star 0%
1 star 0%
wavon Nov 22, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is well organized, thorough, and clearly written. It's helpful for learning what you can do with WordPress without needing to code. The step-by-step instructions are easy to follow, even when you need to make minor edits to php files.Chapter 3, Creating a Network of Sites, is fantastic. Activate WordPress Multisite, and you can use one WordPress installation to create as many sites as you like, or let users create their own. Each site can have different themes and plugins and its own domain name. This setup is ideal for hosting a portfolio site with multiple project sites. It allows updating WordPress, themes, and plugins in a central place rather than for each site separately. If you want to charge users to register a site in your network, you’ll learn how to use PayPal to manage paid memberships.
Amazon Verified review Amazon
Amazon Customer Nov 18, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I've always liked cookbooks for software, because the best way to learn is from example. This book has excellent examples, with a minimum of mistakes or omissions. Using it, I already fixed a faulty website a friend of mine created, and I had never used Word Press before!
Amazon Verified review Amazon
Amazon Customer Nov 18, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Interesting, well presented and dug me out of a problem very quickly as I wanted to combine features from old word press activities and update themI have been through the publication once but need to reread the other elements - however I found what I needed and got the job done quickly because the book was easy to read, follow and implement.
Amazon Verified review Amazon
Jay Dec 21, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
product as described
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela