WordPress Tutorial



Overview

WordPress is an open source Content Management System (CMS), which allows the users to build dynamic websites and blogs. WordPress is the most popular blogging system on the web and allows updating, customizing and managing the website from its back-end CMS and components.

Prerequisites

Before you start with this tutorial, we are assuming that you are already aware about the basics of HTML and CSS. If you are not aware of these concepts, then we suggest you go through our short tutorial on HTML and CSS.

What is Content Management System (CMS)?

The Content Management System (CMS) is a software which stores all the data such as text, photos, music, documents, etc. and is made available on your website. It helps in editing, publishing and modifying the content of the website.

WordPress was initially released on 27th May, 2003 by Matt Mullenweg and Mike Little. WordPress was announced as open source in October 2009.

Features

Advantages

Disadvantages


Installation

System Requirements for WordPress

Download WordPress

When you open the link https://wordpress.org/download/, you will get to see a screen as the following snapshot −

Create Store Database

Set Up Wizard

It's very easy to set up WordPress into your system. The following steps describe how to set up WordPress locally on your system.

Step (1) − Extract the downloaded WordPress folder and upload it into your web server or localhost.

Step (2) − Open your browser and navigate to your WordPress file path, then you will get the first screen of the WordPress installer as shown in the following screen. In our case, the path is localhost/< Your_wordpress_folder >.

Select your language for the WordPress and click on Continue.

Step (3) − In this step, you can view the information needed for the database before proceeding with WordPress installation.

Click on Let's go!

Step (4) − Here, you have to enter the information about the MySQL database as described in the following screen.

After filling all information, click on Submit button.

Step (5) − WordPress checks the database setting and gives you the confirmation screen as shown in the following snapshot.

Click on Run the install

Step (6) − Enter administrative information.

It contains the following fields −

After filling all the information, click on the Install WordPress button.

Step (7) − After installation being successful, you will get a screen of the stating success as seen in the following screen.

You can view your username and password detail added in WordPress.

Click on Log In button.

Step (8) − After clicking on login, you will get a WordPress Admin Panel as depicted in the following screen.

Enter the username and password which you had mentioned during installation as shown in step 6 and click on the Log In button.


Dashboard

The WordPress Dashboard is a first screen which will be seen when you log into the administration area of your blog which will display the overview of the website. It is a collection of gadgets that provide information and provide an overview of what's happening with your blog. You can customize your needs by using some quick links such as writing quick draft, replying to latest comment, etc.

Dashboard can be categorized as shown in the following snapshot. Each of these categories are discussed in the following sections −

Wordpress Dashboard

Dashboard Menu

The WordPress Dashboard provides navigation menu that contains some menu options such as posts, media library, pages, comments, appearance options, plugins, users, tools and settings on the left side.

Screen Options

The dashboard contains different types of widgets which can be shown or hidden on some screens. It contains check boxes to show or hide screen options and also allows us to customize sections on the admin screen.

Welcome

It includes the Customize Your Site button which allows customizing your WordPress theme. The center column provides some of the useful links such as creating a blog post, creating a page and view the front end of your website. Last column contains links to widgets, menus, settings related to comments and also a link to the First Steps With WordPress page in the WordPress codex.

Quick Draft

The Quick Draft is a mini post editor which allows writing, saving and publishing a post from admin dashboard. It includes the title for the draft, some notes about the draft and save it as a Draft.

WordPress News

The WordPress News widget displays the latest news such as latest software version, updates, alerts, news regarding the software etc. from the official WordPress blog.

Activity

The Activity widget includes latest comments on your blog, recent posts and recently published posts. It allows you to approve, disapprove, reply, edit, or delete a comment. It also allows you to move a comment to spam.

At a Glance

This section gives an overview of your blog's posts, number of published posts and pages, and number of comments. When you click on these links, you will be taken to the respective screen. It displays the current version of running WordPress along with the currently running theme on the site.


General Setting

In this chapter, we will study about General Settings in WordPress. WordPress general setting is used to set the basic configuration settings for your site. In the setting administration screen, it is a default setting screen.

Following are the steps to access the general settings −

Step 1 − Click on Settings → General option in WordPress.

WordPress General Setting

Step 2 − The General Setting page is displayed as shown in the following snapshot.

WordPress General Setting

Following are the details of the fields on general settings page.

Step3 − After filling all the information about general settings, click on Save Changes button. It saves all your general setting information.


Writing Setting

The writing settings controls the writing experience and provides options for customizing WordPress site. These settings control the features in the adding and editing posts, Pages, and Post Types, as well as the optional functions like Remote Publishing, Post via e-mail, and Update Services.

Following are the steps to access the writing settings −

Step (1) − To change writing settings, go to Settings → Writing option.

WordPress Writing Setting

Step (2) − The Writing Setting page is displayed as shown in the following screen.

WordPress Writing Setting

Following are the details of the fields on the page.

Step (3) − After filling all the above information, click on Save Changes button to save your information.


Reading Setting

In this chapter, we will study about Reading Settings in WordPress. Reading Setting is used to set the content related to the front page. You can set the number of post to be displayed on the main page.

Following are the steps to access the reading settings −

Step (1) − Click on Settings → Reading option in WordPress.

WordPress Reading Setting

Step(2) − The Reading Settings page is displayed as shown in the following screen.

WordPress Reading Setting

Following are the details of the fields on reading settings.

Step(3) − After filling all the information, click on Save Changes button to save your Reading Setting information.


Discussion Setting

In this chapter, we will study about Discussion settings in WordPress. WordPress discussion setting can be defined as the interaction between the blogger and the visitors. These settings are done by the admin to have a control over the posts/pages that come in through users.

Following are the steps to access the Discussion setting −

Step (1) − Click on Settings → Discussion option in WordPress.

WordPress Discussion Setting

Step (2) − The Discussion Settings page is displayed as shown in the following snapshot.

WordPress Discussion Setting

Following fields are seen in Discussion settings.

Step (3) − Click on Save Changes button to save the changes.


Media Setting

In this chapter, we will study about Media Settings in WordPress. It is used to set the height and width of the images which you're going to use on your website.

Step (1) − Click on Settings → Media option in WordPress.

Wordpress Media Setting

Step (2) − The Media Settings page is displayed as seen in the following screenshot.

Wordpress Media Setting

Following are the details of the fields on Media settings −

Step (3) − After setting the dimension in pixels, click on Save Changes button. It saves your media setting information.


Permalink Setting

In this chapter, we will learn about Permalink settings in WordPress. Permalink is a permanent link to a particular blog post or category. It allows setting the default permalink structure. These settings are used to add permalinks to your posts in WordPress. Following are the steps to access permalink settings.

Step (1) − Click on Settings → Permalinks option from the left navigation menu.

Wordpress Permalink Settings

Step (2) − When you click on Permalinks, the following page appears on the screen.

Wordpress Permalink Settings

Here are a few settings you can make −

Step (3) − Once you are done with changes, click on Save Changes button to save the permalink settings.


Plugin Setting

In this chapter, we will study how to use plugins in your WordPress site. Plugin allows to easily modify, customize or enhance WordPress blog or post. The WordPress Plugin is a software that can be uploaded to expand the functionality of the site. They add services or features to WordPress blog. Plugins are used to make your work easier. Following are the simple steps to add plugins.

Step (1) − On the left side bar, Click on Plugins → Installed Plugins as shown in the screen.

Wordpress Plugin Settings

Step (2) − The following page appears.

Wordpress Plugin Settings

In this section, you can view the already installed plugins.

Step (3) − Click on → Plugins → Add New menu as shown in the following screen.

Wordpress Plugin Settings

Step (4) − A list of plugins appears that are used in WordPress. Here you can directly install plugins from the available list or you can upload it by clicking on Upload Plugin.

Wordpress Plugin Settings

When you click on Upload Plugin you'll get the following page.

Wordpress Plugin Settings

Click on Browse, it goes back to the page where you can select plugins from WordPress site. And if you click on Choose File, you can add files from your system. Otherwise, you can directly choose the plugin that you need and click on Install now as seen in the following screenshot.

Wordpress Plugin Settings

When you click on Install Now, the package starts to download and gets installed. Then, click on Activate plugin to active that plugin to use in WordPress as seen in the following screen.

Wordpress Plugin Settings

After clicking on Activate Plugin you'll get a message as Plugin activated and you can also find the installed plugin in the list.

Wordpress Plugin Settings

Below the plugin activated message, you can view few options such as All, Active, Inactive and Update available.

When you click on Active the following page appears. Here you can view all the activated plugins.

Wordpress Plugin Settings

When we click on Inactive, the plugins which are available but are not activated gets displayed. You can activate this plugin by clicking on Activate.

Wordpress Plugin Settings

When you click on Update available, you'll get a list of plugins that must be updated. Click on Update and you get a message as Updated.

Wordpress Plugin Settings

Click on Bulk Actions and select any of the options. Click on Apply button to update, delete, activate or deactivate each of the plugins by checking the boxes.

Wordpress Plugin Settings

In Search Installed Plugins you can just type your plugin name in the text box that is already installed and click on the Search Installed Plugins button.

Wordpress Plugin Settings

When you click on the Search installed Plugin button you get the following page with your respective plugin.

Wordpress Plugin Settings

Step (5) − Click on Plugins → Editor from the side bar.

Wordpress Plugin Settings

Step (6) − The following page gets displayed.

Wordpress Plugin Settings

This page lets you edit your plugins. A few options are explained.

Finally, after editing the plugin files, click on Update file.


Add Category

In this chapter, we will study about how to Add Categories in WordPress. Category is used to indicate sections of your site and group related posts. It sorts the group content into different sections. It is a very convenient way to organize the posts.

To access the Category section, follows the mentioned steps −

Step (1) − Click on Posts → Categories option in WordPress.

WordPress add category

Step (2) − The Categories page is displayed as shown in the following screenshot.

WordPress add category

Following are the details of the fields on Categories.

Step (3) − After filling all the information about Categories, click on Add New Category button.

Step (4) − After clicking on Add New Category, the new created category will get displayed on the right side of the page as shown in the following screen.

WordPress add category

Edit Category

In this chapter, we will study the simple steps to Edit Categories in WordPress.

Following are the simple steps to edit categories in WordPress.

Step (1) − Click on Posts → Categories in WordPress.

WordPress Edit Category

Step (2) − You can view Category1 (Category1 was created in the chapter WordPress - Add Category). When the cursor hovers on the Categories, then a few options get displayed below the Category name. There are two ways to edit the categories i.e. Edit and Quick Edit

Edit − Click on Edit option in Categories section as seen in the following screenshot.

WordPress Edit Category

You can edit any of the required field, and then click Update button as shown in the following screen.

WordPress Edit Category

Category fields are same from the chapter WordPress - Add Category.

Quick Edit − Click on Quick Edit option in Categories section as shown in the following screen.

WordPress Edit Category

Here, you can only edit the Name and Slug of the category as seen in the following screen and then finally click on Update Category button.

WordPress Edit Category

Delete Category

In this chapter, we will study about how to Delete Categories in WordPress.

Following are the simple steps to delete categories in WordPress.

Step (1) − Click on Posts → Categories in WordPress.

WordPress delete category

Step (2) − You can delete Category1 (Category1 was created in the chapter Wordpress - Add Category). When the cursor hovers on the Categories, a few options get displayed below the Category name. Click on Delete button as shown in the following screen.

WordPress delete category

When you click on delete, you will get a pop message asking for confirmation to delete the particular category as shown in the following screenshot.

WordPress delete category

You can click on OK button and delete the category permanently.


Arrange Categories

In this chapter, we will study about how to Arrange Categories in WordPress. You can't arrange categories directly in WordPress. Hence, you will need to install Category Order plugin to arrange the created categories in a particular way.

Step (1) − Click on Posts → Category Order in WordPress. The Category Order menu displays after adding the Category Order plugin. You can study how to install plugins in the chapter Install Plugins.

WordPress arrange category

Step (2) − In the following screen, you can see that the create categories section are not in order.

WordPress arrange category

Step (3) − Now, you can rearrange your categories by just dragging the categories as per your choice. Click on Order categories button to save the ordered categories.

WordPress arrange category

Add Posts

In this chapter, we will study how to Add Posts in WordPress. Posts are also known as articles and sometimes referred as blogs or blog posts. These are used to popularize your blogs.

Following are the simple steps to Add Posts in WordPress.

Step (1) − Click on Posts → Add New in WordPress.

WordPress Add Posts

Step (2) − You will get the editor page of the Post as shown in the following screen. You can use the WordPress WYSIWYG editor to add the actual content of your post. We will study in detail about WYSIWYG editor in the chapter WordPress - Add Pages.

WordPress Add Posts

Following are the fields on the editor page of the Add Posts Page.

Step (3) − Click on Publish button to publish your respective post.

Wordpress Add Posts

Following are the few other options present in the Publish section.


Edit Posts

In this chapter, we will study how to Edit Posts on WordPress.

Following are the simple steps to Edit Posts in WordPress.

Step (1) − Click on Posts → All Posts in WordPress.

WordPress Edit Posts

Step (2) − You can view Post1 (Post1 was created in the chapter WordPress - Add Posts). When the cursor hovers on the Post, few options get displayed below the Post name. There are two ways to edit the Post i.e. Edit and Quick Edit.

Edit − Click on Edit option in Post1 as shown in the following screen.

WordPress Edit Posts

You can edit or change the content or title of the post as per your needs, and then click on Update button as shown in the following screen.

WordPress Edit Posts

Quick Edit − Click on Quick Edit option in Post1 as shown in the following screenshot.

WordPress Edit Posts

Here you can edit the Title, Slug and date of the posts and can also select the categories for your post as shown in the following screenshot and then click on Update button to confirm post edits.

WordPress Edit Posts

Delete Posts

In this chapter, we will study how to Delete Posts in WordPress.

Following are the steps to Delete Posts in WordPress.

Step (1) − Click on Posts → All Post in WordPress.

WordPress delete posts

Step (2) − You can delete Post1 (Post1 was created in the chapter Wordpress - Add Posts). When the cursor hovers on the Post, then a few options get displayed below Post1. Click on Trash option to delete the post.

WordPress delete posts

Step (3) − You can view your post lists to confirm if the above post is deleted.

WordPress delete posts

Preview Posts

In this chapter, we will study how to Preview Posts in WordPress. Preview Post is to view the post before it is published to the user. It is safer to preview your post and verify how your post looks on the website. You can edit or change the post as per your need after previewing.

Following are the simple steps to Preview Posts in WordPress.

Step (1) − Click on Posts → All Posts in wordPress.

WordPress preview posts

Step (2) − You can view Post1 (Post1 was created in the chapter Wordpress - Add Posts). When the cursor hovers on the Post, then a few options get displayed below the Post name. Click on the View option as shown in the following screenshot.

WordPress preview posts

Or else you can view your post directly while editing or adding post by clicking on the Preview button as shown in the following screen.

WordPress preview posts

Step (3) − You can view your post, when you click on View or Preview.

WordPress preview posts

Publish Posts

In this chapter, we will study how to Publish Posts in WordPress. Publish is used to make the post available to all the users wherein every user can view that particular post. Publishing a new post in WordPress is an easy process.

Following are the steps to Publish Posts in WordPress.

Step (1) − Click on Posts → Add New in WordPress.

WordPress Publish Posts

Step (2) − You will get the editor page of the Post as shown in the following screenshot. You can use the WordPress WYSIWYG editor to add the actual content of your post.

WordPress Publish Posts

Step (3) − Click on Publish button to publish your respective post.

WordPress Publish Posts

After clicking on publish, your posts get published for the user to view it.


Media Library

In this chapter, we will learn about Media Library in WordPress. Media Library consists of the images, audios, videos and files that you can upload and add to the content when writing a Post or Page. Here you can view, add, edit or delete any media related objects if not needed.

Following are the steps to understand about Media Library.

Step (1) − Click on Media → Library in WordPress.

WordPress Media Library

Step (2) − You can view media files like images, audios, videos. Click on Add Media button.

WordPress Media Library

Step (3) − The Upload New Media page gets displayed. You can learn how to Add Media in the next chapter.

WordPress Media Library

Step (4) − You can view a bar as shown in the following screenshot.

WordPress Media Library

The various tabs that appear have the following functions −

List View − Displays the images and videos in list form.

WordPress Media Library

Grid View − Displays all images in the grid format as shown in the following screen.

WordPress Media Library

Filter the images and videos − Filters the images and videos.

Search Box − Helps to search a particular image by inserting the name into the box.


Add Media

In this chapter, we will study how to Add Media files in WordPress. WordPress allows you to add, all kind of media files like videos, audios and images.

Following are the steps to Add Media.

Step (1) − Click on Media → Add New in WordPress.

WordPress Add Media

Step (2) − Then, click on Select Files option to select the files from your local storage as shown in the following figure.

WordPress Add Media

Step (3) − Add Media files such as images and audios by selecting them and click open as shown in the following screenshot.

WordPress Add Media

Step (4) − You can view the list of media files added as shown in the following screenshot.

WordPress Add Media

Insert Media

In this chapter, we will study how to Insert Media in WordPress. Media files can be inserted to your Pages or Posts from libraries, from local storage or from URLs.

Following are the steps to Insert Media in WordPress.

Step (1) − Click on Posts → Add New in WordPress.

WordPress Insert Media

Step (2) − Click on Add Media.

WordPress Insert Media

Step (3) − You can select the files from the Media Library tab as shown in the following screenshot.

WordPress Insert Media

Information about the selected media file will be displayed on the right side of the screen under the Attachment Details. Click on Insert Post button, the image will be inserted into the post. In Attachment Details section, you will find information about the images such as URL, Title, Caption, Alt Text and Description

You can also insert an image directly from your system by clicking on Upload Files tab. Click on Insert into Post button.

WordPress Insert Media

Edit Media

In this chapter, we will study how to Edit Media in wordPress. You can manage all the information about your media that is saved in the Media Library.

Following are the steps to Edit Media in WordPress.

Step (1) − Click on Media → Library and click on the name of the media item or the edit link.

WordPress edit media

Step (2) − You will view a list of media files. Select any one image to edit.

WordPress edit media

Step (3) − You can view the edit media page with few options on the right side.

WordPress edit media

Step (4) − Once you complete editing the required fields, click on Update button to save the changes made to an image.

WordPress edit media

Add Pages

In this chapter, we will study how to Add Pages into the WordPress. Adding pages is similar to adding posts in WordPress. Pages are static content and often do not change its displayed information.

Following are the simple steps to add pages in WordPress.

Step (1) − Click on Pages → Add New as shown in the following screenshot.

WordPress Add Pages

Step (2) − You will get the editor page as seen in the following screenshot. The editor page has two tabs, Visual and Text. You can insert text in either of these. Here, we'll study about inserting text into Visual format.

WordPress Add Pages

Following are the details of the fields on editor page of the Add New Page.

Title

It is used to write the title of the article, which is later displayed on the page.

Permalink shows the potential URL for the page below the title. The URL generates as per the given title.

WordPress Add Pages

WYSIWYG Editor

It is a WYSIWYG Editor, which is similar to a word processor interface where you can edit the contents of the article.

WordPress Add Pages

Following are the options present of WYSIWYG editor −

Wordpress Add Pages

Following are the fields present in the Insert/edit link.

Wordpress Add Pages WordPress Add Pages WordPress Add Pages

Text Insertion

For writing the content of an article.

Publish

To publish the page to the user on the website.

Page Attribute

Page attributes module allows you to select the parents for your particular page. You can also set order of the pages.

WordPress Add Pages

Featured Images

Includes the images in the pages.


Publish Pages

In this chapter, we will study how to Publish Pages in WordPress. The command, “Publish” is used to make the pages available to all users wherein each user can view that particular page. Publishing a new page in WordPress is an easy process.

Following are the steps to Publish Pages in WordPress.

Step (1) − Click on Pages → Add New in WordPress.

WordPress Publish Pages

Step (2) − You will get the editor as shown in the following screenshot. You can use the WordPress WYSIWYG editor to add the actual content of your page.

WordPress Publish Pages

Step (3) − Click on Publish button as shown in the following screen.

WordPress Publish Pages

After clicking on publish, your posts get published for the user to view it.


Edit Pages

In this chapter, we will study how to Edit pages in WordPress.

Step (1) − Click on Pages → All Pages in WordPress as shown in the following screen.

WordPress Edit Pages

Step (2) − You can view About Us (About Us was created in the chapter WordPress - Add Pages). When the cursor hovers on the pages, then few options get displayed below About Us. There are two ways to edit the Post, i.e., Edit and Quick Edit.

Edit − Click on Edit option in About Us as shown in the following screenshot.

WordPress Edit Pages

You can edit or change the content or title from the page as per your need, and then click on Update button as shown in the following screen.

Wordpress Edit Pages

Quick Edit − Click on Quick Edit option in About Us as shown in the following screen.

WordPress Edit Pages

You can edit the Title, Slug and date of the About Us page and can also select the parent for your page as shown in the following shot and then click on Update button.

WordPress Edit Pages

Delete Pages

In this chapter, we will learn to Delete Pages in WordPress.

Following are the steps to Delete pages in wordPress.

Step (1) − Click on Pages → All Pages in WordPress.

WordPress Delete Pages

Step (2) − You can delete Sample Page (Sample Page is created by default in WordPress). When the cursor hovers on the pages, then a few options gets displayed below the Sample Page. Click on Trash option to delete the post.

WordPress Delete Pages

Or alternatively you can also delete your page directly while editing or adding page by clicking on the Move to Trash button as shown in the following screen.

WordPress Delete Pages

Step (3) − To confirm that you have deleted the page, view your page list.

WordPress Delete Pages

Add Tags

Tag is a small information attached to the main content or post for the purpose of identification. It tells the visitors what actually the post is about. If the tag is mentioned properly then it helps to find the content very easily.

Following are the steps to Add Tags in WordPress.

Step (1) − Click on Posts → Tags in WordPress.

WordPress Add Tags

Step (2) − The Tags page is displayed.

WordPress Add Tags

Following are the details of the fields on Tags.

After filling all the information about Tags, click on Add New Tag button.

Step (3) − The new created tags will get displayed on the right side of the page as shown in the following screenshot.

WordPress Add Tags

Edit Tags

In this chapter, we will study to Edit Tags in WordPress. You can learn how to add tags in the chapter WordPress - Add Tags.

Following are the simple steps to Edit Tags in WordPress.

Step (1) − Click on Posts → Tags in WordPress.

WordPress Edit Tags

Step (2) − You can view tag Food around the world (Food around the world was created in the chapter Wordpress - Add Tags). When the cursor hovers on the Tags, then a few options get displayed below the Tag name. There are two ways to edit the tags i.e. Edit and Quick Edit

Edit − Click on Edit option in Tags section as shown in the following screen.

WordPress Edit Tags

You can edit any of the required field, and then click on Update button as shown in the following screen.

Wordpress Edit Tags

Here tag fields are same from the chapter WordPress - Add Tags.

Quick Edit − Click on Quick Edit option in Tags section as shown in the following screenshot.

WordPress Edit Tags

Here you can only edit the Name and Slug of the Tags as seen in the following screen and then click on Update Tag button.

WordPress Edit Tags

Delete Tags

In this chapter, we will learn to Delete tags in WordPress.

Following are the steps to delete tags in WordPress.

Step (1) − Click on Posts → Tags in WordPress.

WordPress Delete Tags

Step (2) − You can delete tag Food around the world (Food around the world was created in the chapter WordPress - Add Tags), when the cursor hovers on the Tags, then a few options get displayed below the Tags name. Click on Delete in tags section as shown in the following screen.

WordPress Delete Tags

When you click on delete, you will get a pop message asking for confirmation to delete.

WordPress Delete Tags

You can click on OK button and delete the tag permanently.


Add Links

In this chapter, we will learn to Add Links in WordPress pages. Link is a connection from one resource to another. Adding links to your pages or blog posts help you to connect to other pages.

Following are the simple steps to Add links in WordPress.

Step (1) − Click on Pages → All Pages in WordPress.

WordPress Add Links

Step (2) − List of pages created in WordPress will get displayed as shown in the following screen. Select any of the pages to add links inside it. Here, we are going to add links in About Us page.

WordPress Add Links

Step (3) − Select any of the sentence or word where you want to add link. Here, we will add link to the word Lorem.

WordPress Add Links

Step (4) − When you click on the Insert/Edit link symbol then the following pop window gets displayed.

WordPress Add Links

Following are the fields present in the Insert/edit link.

WordPress Add Links

After selecting the particular page or post from the list, the links get created in the URL field as seen in the preceding screen. Click on Add Link.

Step (5) − When you hover on the word Lorem then the link tooltip gets displayed as shown in the following screen.

WordPress Add Links

Click on Update button to update the changes in your page or post.


Edit Links

In this chapter, we will study how to edit link in WordPress.

Following are the simple steps to Edit Links in WordPress

Step (1) − Click on Pages → All Pages as shown in the following screen.

WordPress Edit Links

Step (2) − You can view the list of pages. When the cursor hovers on the About Us page, then a few options get displayed below About Us. Click on Edit as shown.

WordPress Edit Links

Step (3) − Hover on the word Lorem (Link for word Lorem was created in the chapter WordPress - Add Links), and click on the pencil symbol to edit the link as shown in the following screen.

WordPress Edit Links

Step (4) − You can change or edit your link by selecting the page from the existing list. In this case, we have selected the About Us page.

WordPress Edit Links

After selecting the particular page or post from the list, then click on Update button.

Step (5) − When you hover on the word Lorem then the link tooltip get displayed as seen in the following screen.

WordPress Edit Links

Click on Update button to update the changes in your page or post.


Delete Links

In this chapter, we will learn to Delete links from WordPress. You can remove the unwanted links which you don’t need for your website or article.

Following are the steps to Delete Links in WordPress

Step (1) − Click on Pages → All Pages in WordPress.

WordPress Delete Links

Step (2) − You can view the list of pages. When the cursor hovers on the About Us page, then a few options gets displayed. Click on the Edit button as shown in the following screen.

WordPress Delete Links

Step (3) − Select the word which you had already linked i.e. Lorem (Link for word Lorem was created in the chapter WordPress - Add Links), and click on the Remove Link Symbol as seen in the following screen.

WordPress Delete Links

Step (4) − When you hover on the word Lorem, there will be no tooltip of the existing URL. The following screenshot shows that the link has been deleted.

WordPress Delete Links

Add Comments

In this chapter, we will learn to Add Comments in WordPress. Adding comments allows your visitors to have a discussion with you. Comments are approved by the admin and then posted to be discussed further.

Following are the steps to add comments to your blog posts.

Step (1) − Click on Pages → All Pages in WordPress.

WordPress Add Comments

Step (2) − The list of pages created in WordPress will get displayed as seen in the following screen. Select any of the pages you want to add comments to. Here, we are going to add comment in About Us page. Click on About Us.

WordPress Add Comments

Step (3) − To add a comment on this page, click on Screen options present at the top right hand corner.

WordPress Add Comments

Step (4) − The dropdown list of Screen Option gets displayed. Check the Discussion and Comments box as shown in the following screen.

WordPress Add Comments

Step (5) − You can now view the Discussion and Comments box at the bottom of your page.

WordPress Add Comments

In the Discussion section, there are two options present −

In the Comment section, you can add comments by clicking on Add Comment button.

Step (6) − Click on Update button after adding the comment box.


Edit Comments

In this chapter, we will learn about how to Edit comments in WordPress. Editing comments can be done only by the admin.

Following are the steps to Edit Comments in WordPress.

Step (1) − Click on Comments in WordPress.

WordPress Edit Comments

Step (2) − You can view the comments list for the various pages. Select any comment, you want to edit. Click on edit.

WordPress Edit Comments

Step (3) − The Edit comment page gets displayed. You can edit the comment and click on Update Button.

WordPress Edit Comments

Here you can edit the name, e-mail, URL or the comment from the comment box.


Moderate Comments

In this chapter, we will learn to Moderate Comments in WordPress. Comment moderation is a process where, when visitors comment on posts, the comment is not published directly until and unless it is approved by the admin to be posted. It manages your comments so that there is no comment spamming.

Step (1) − Click on Settings → Discussion in WordPress.

WordPress Moderate Comments

Step (2) − The Discussion Setting page gets displayed.

WordPress Moderate Comments

In the Comment Moderation field, enter those words or URLs you do not want any visitor to add comments. Whenever a visitor gives any comments it would be moderated by the admin first and then published.

Step (3) − Click on Save Changes.


View Plugins

In this chapter, we will study how to View Plugins in WordPress. It helps you to enable and disable WordPress Plugins. This adds the unique features to an existing web site. Plugins extend and enlarge the functionality of WordPress.

Following are the simple steps to View Plugins in WordPress.

Step (1) − Click on Plugins → Installed Plugins in WordPress administrator.

WordPress View Plugins

Step (2) − You will see the list of existing plugins on your site as seen in the following screen.

WordPress View Plugins

A table of Plugin and Description is displayed. Names of the plugins are defined in Plugin column and a brief description about the plugin is defined under Description column.

Toolbar

Following functions appear as Plugin toolbar options on the page −


Install Plugins

In this chapter, we will study how to install plugins in WordPress. It is really easy to install plugins. All the plugins are free to download; the only condition is that a plugin must be in the WordPress directory.

Following are the simple steps to Install Plugins in WordPress.

Step (1) − Click on Plugins → Add New in WordPress.

wordPress install plugins

Step (2) − Enter your required plugin name in the search box as shown in the following screen. List of plugins which are relevant to the plugins name will get displayed as seen in the following screen.

wordPress install plugins

Select the required plugin you want to use. Here, we have searched All in one SEO Pack plugin, which happens to be the first plugin as shown in the preceding screen. Click on install now button to install the plugin on your website.

Step (3) − The plugins automatically start downloading and installing.

wordPress install plugins

Click on Activate Plugin to activate the plugin on your website, which makes your task much easier using this plugin.

Step (4) − Once activated, you will see the installed plugin in the list of plugins as seen in the following screen.

wordPress install plugins

Customize Plugins

In this chapter, we will study how to Customize Plugins in WordPress without writing any HTML or CSS. It's usually a large addition for multi-user sites. This new method allows you to customize your login page by using the WordPress theme customizer (no coding skills required).

Following are the simple steps to Customize Plugins in WordPress.

Step (1) − Click on Plugins → Add New.

wordPress customize plugins

Step (2) − Install and activate the Custom Login Page Customizer Plugin.

wordPress customize plugins

Step (3) − Click on Appearance → Login Customize section.

wordPress customize plugins

Step (4) − Click on Start Customizing button to proceed further.

wordPress customize plugins

Step (5) − It will launch the built-in WordPress theme customizer. You can customize the theme and make it look the way you want.

wordPress customize plugins

Click on the new Login Customizer tab in the side panel. Login customizer page will get displayed. On the login customizer page, you can customize your login page in the same way as you customize your WordPress theme.

Step (6) − The customized login page will appear as shown in the following screen.

wordPress customize plugins

Most of the selections in the customizer panel are transparent. You can check all the selections in the customizer to adjust the setting as per your requirement of your login page. Click on Save and Publish button.


User Roles

In this chapter, we will learn about the roles of users in WordPress. Every user has their own role in WordPress. Roles are like permissions given to a particular user to access the WordPress site. These roles can be allotted only by the Admin.

Here are few pre-defined roles available in WordPress −


Add Users

In this chapter, we will study how to Add users to your WordPress blog or website. When users register on your WordPress blog or website, you get an e-mail notification, so you always know when new users register, and you can then get into your Dashboard and edit the users’ role.

Following are the simple steps to Add Users in WordPress.

Step (1) − Click on Users → Add New in WordPress.

WordPress Add Users

Step (2) − You can fill the user detail on the Add New User page. Fill in all the required fields (as seen in the following screen) to proceed further.

WordPress Add Users

Click on Add New User button to add user to your users list.

Step (3) − You can view the user list to see whether the users have been added. A message will be displayed as New User Created as seen in the following screen.

WordPress Add Users

User Photo

In this chapter, we will study about User Photo in WordPress. To add user photo in WordPress, you must install plugin User Photo from WordPress plugins. It helps you add a photo of your own to your WordPress profile.

Following are the simple steps to add a User photo.

Step (1) − Click on Settings → User Photo.

WordPress User Photo

Step (2) − The User Photo Options page gets displayed.

WordPress User Photo

Set the dimension for your thumbnails and make the required changes and then click on Update Options button.

Step (3) − To view the plugin User Photo is activated, go to Users → Your Profile. In your Profile page you can see Your Photo section is added. Here you can upload your photo to display as profile image.

WordPress User Photo

Edit Users

In this chapter, we will study how to Edit Users in WordPress.

Following are the simple steps to Edit Users in WordPress.

Step (1) − Click on Users → All Users.

WordPress Edit Users

Step (2) − You will see a list of users.

WordPress Edit Users

There are two more tabs seen on the toolbar −

When we click on the Change role to box, a dropdown list appears as seen in the preceding screenshot.

Click on the check box of the user name to change the role of the user. Then, click on change button and the user's role will be changed accordingly.

Step (3) − Click on Edit option as shown in the following screen to edit the user.

WordPress Edit Users

Step (4) − The Edit User page is displayed. Here you can edit or modify all the fields as per your need and click on Update User to save the changes.

WordPress Edit Users

Delete Users

In this chapter, we will learn how to delete users in WordPress.

Following are the steps to Delete Users.

Step (1) − Click on Users → All Users.

WordPress Delete User

Step (2) − List of Users gets displayed as shown in the following screen.

WordPress Delete User

Step (3) − Select the one you want to delete. And click on Delete.

WordPress Delete Pages

Step (4) − When you click on Delete you get the following page.

WordPress delete User

Step (5) − Select options as required and click on Confirm Deletion. Your user will be deleted.

Step (6) − We have another method of deleting users. A screen as shown in the following shot appears.

Here you can select the users to delete, check the boxes and click on Delete from the dropdown list and click on Apply.

Step (7) − Once you click on Apply, the users selected will be deleted.

WordPress Delete User

Personal Profile

In this chapter, we will learn how to create a Personal profile in WordPress.

Following are the steps to Personal Profile.

Step(1) − Click on Users → Your Profile from the left navigation bar.

WordPress Personal Profile

Step (2) − When you click on ‘Your profile’ the following screen will be displayed.

WordPress Personal Profile

The following Personal options appear on the screen −

Name

Contact Info

About yourself

Step (3) − After you have updated all the changes, click on Update Profile.


Theme Management

In this chapter, we will learn about Theme management. It includes image files, templates, CSS stylesheets, etc. that can help to make your website look great. This chapter discusses how to install, add new, or customize themes in WordPress.

Following are the steps for Theme Management.

Step (1) − Select Appearance → Themes from the dashboard.

WordPress Theme Manegement

Step (2) − The following screen will be displayed. Hover over any theme and click on Theme Details.

WordPress Theme Management

WordPress Theme Management

Step (3) − When you click on Theme Detail the following page appears. It consists of details related to the theme. Details like version, description, tags etc.

WordPress Theme Management

If you want to add this theme to your page/website then click on Activate, and if you want to just check the theme, then click on Live preview.

If you click on activate then you get a pop-up message as −

WordPress Theme Management

Step (4) − Click on Customize.

WordPress Theme Management

Step (5) − On the left side of the page, you can customize your theme. Any changes you make or anything new you add is displayed on the right side of the page.

WordPress Theme Management

We will learn about customizing the appearance of the themes in the next chapter i.e.; WordPress Customize Theme.


Customize Theme

In this chapter, we will learn how to customize themes. Customizing themes help you to give a new look to your website. Here you can change background images/colors, add titles, and do much more.

Following are the steps of Customize theme.

Step (1) − Click on Appearance → Customize.

WordPress Customize Theme

Step (2) − The following screen will be displayed.

WordPress Customize Theme

As can be seen, on the left side we have the customizing section, and on the right side we have the theme you have chosen. So any changes you make on the left side will be displayed on the right side of the page. Here are a few options you must know −

Active theme − In this section, you can change the current theme just by clicking on ‘Change’.

WordPress Customize Theme

When you click on ‘Change’ you get a list of themes, click on any of the themes, and then click ‘Save & Continue’. Your theme will be saved.

WordPress Customize Theme

Site Title & Tagline − In this section, you can add the site title and tagline you want to add to your website.

WordPress Customize Theme

Add your title name in the ‘Site Title’ section. And your tagline in the ‘Tagline’ box.

Colors − You can change your header text color using this section. As you scroll through the colors you find changes happening on the right side of your page. You can even add a color of your own into the box that is situated in between ‘Current color’ and ‘Default’.

WordPress Customize Theme

Header Image − Add a header image either by selecting from the suggestions or you can add an image of your own by clicking on ‘Add new image’.

WordPress Customize Theme

Widgets − Add widgets to your site from here.

WordPress Customize Theme

When you click on the arrow mark the following image appears.

WordPress Customize Theme

Here, there are two options −

First is the ‘Main Widget Area’, when you click on this you get another list of widgets that are to be displayed in the footer area.

WordPress Customize Theme

When you click on any of the widgets a dropdown appears where you can edit more or add more. For example − If you want to add categories then the following image appears.

WordPress Customize Theme

In this image, as you can see, you can add your category in the ‘Title’ section. Check any of the required boxes. If you do not want to add any, then say ‘Remove’. Same goes for other widgets too.

Secondary Widget − Here you must click on ‘Add a widget’ and you get a side bar with a list of different widgets. Click on any and it adds up to your widget list.

WordPress Customize Theme

If you want to add more widgets then click on ‘Add a widget’ again and you can add as many widgets as you want.

WordPress Customize Theme

Static Front − Select either latest posts or static front page for your site.

WordPress Customize Theme

Widget Management

In this chapter, we will study about Widget Management. Widgets are small blocks that perform specific functions. These give design and structure control to the WordPress theme. Some specific features of a widget are −

Step (1) − Click on Appearance → Widgets.

WordPress Widget Management

Step (2) − The following screen showing available widgets appear.

WordPress Widget Management

The following functions appear on the page −

WordPress Widget Management

WordPress Widget Management

Step (3) − Drag and drop in the Sidebar Main. Any widget you add here, shows up on your site.

WordPress Widget Management

Background

In this chapter, we will study about background images, background colors and background opacity.

Step (1) − Click on Appearance → Background.

WordPress Background

Step (2) − The following page appears where the Background Image section shows up.

WordPress Background

Step (3) − There’s no image selected for background. If you want to do so, then click on Select Image. You get the following page.

WordPress Background

Here you can upload images using two options.

Step (4)Upload Files − When you click on Upload files the following screen is displayed. Select files from your desktop and then click on Choose Image if satisfied with the image.

WordPress Background

Step (5)Media Library − When you click on Media Library the following page appears. Select files from the WordPress media library, which means, if you already have images updated then you can select any of them directly.

WordPress Background

After selecting an image, on the right side you will get a few options −

WordPress Background

Step (6) − Click on Colors → Background Color on the same page. Change your background color accordingly. Background Opacity is not used for all themes. Theme customization is not same for every theme we use. It changes from theme to theme.

WordPress Background

Host Transfer

In this chapter, we will study how to transfer WordPress to a new hosting platform.

Here, we have used Hostinger web hosting to transfer the WordPress site to another host.

Just follow the simple steps given below to transfer your WordPress site to another host.

Step (1) − Keep the backup of WordPress files and export the database. We will study about this in detail in the chapter WordPress - Backup & Restore

Step (2) − Login to your cPanel and click on MySQL Databases as shown in the following screen.

WordPress Host Transfer

Step (3) − Create a new database and MySQL user as shown in the following screen. The page has the following fields −

WordPress Host Transfer

After filling all the fields, Click on Create button.

Step (4) − You can view your created MySQL database, User and Host as shown in the following screen.

WordPress Host Transfer

Step (5) − Click on + symbol.

WordPress Host Transfer

Step (6) − Click on phpMyAdmin.

WordPress Host Transfer

Step (7) − Click on Import tab on the phpMyAdmin page.

WordPress Host Transfer

Step (8) − Click on Choose File button to select the backup file from your system and click on Go button.

WordPress Host Transfer

Step (9) − You can view the tables of database uploaded as shown in the following screen.

WordPress Host Transfer

Step (10) − Upload your WordPress files by using file transfer protocol(FileZilla) as shown in the chapter WordPress - Backup & Restore in Restoring WordPress Files section.

Step (11) − Edit wp-config.php file as mentioned in the Restoring WordPress Files section in chapter WordPress - Backup & Restore.

Step (12) − Inside the Website section of hostinger, Click on Auto Installer.

WordPress Host Transfer

Step (13) − You can view the uploaded file of the WordPress. Click on the URL link as shown in the following screen.

WordPress Host Transfer

Step (14) − You can view the login page of WordPress.

WordPress Host Transfer

Version Update

In this chapter, we will study how to update version in WordPress. Here, we will upgrade WordPress to the latest version through the admin panel.

Following are a few simple steps to update the version in WordPress.

Step (1) − Click on Please Update Now as shown in the following screen.

WordPress Version Update

You will get notifications in WordPress admin panel when there is a newer version available for WordPress. Before updating, it is advised to keep WordPress backup.

Step (2) − After clicking on the update link, the following page gets displayed. Click on Update Now button.

WordPress Version Update

Step (3) − The following message gets displayed during the upgradation of WordPress.

WordPress Version Update

Note − While updating the version, if you get an error as

Fatal error: Maximum execution time of 30 seconds exceeded in C:\your wordpress folder\wp-includes\class-http.php on line 1597

then you need to take the following actions −

Now your WordPress is successfully upgraded.


Spam Protection

In this chapter, we will learn how to protect your WordPress blog or website from spam. Make sure that your WordPress script is updated to the latest stable version. WordPress comes with a preinstalled antispam solution - Akismet.

You can activate Akismet, for which you should have a WordPress API key. You have to register at the official WordPress website. The key will be sent to your mail box.

Following are the steps to follow to enable Akismet Spam Protection plugin for your website or blog.

Step (1) − Go to your WordPress admin area → Plugins → Installed. The following screen will be displayed.

WordPress Spam Protection

Step (2) − Click on Activate button as shown in the following screen.

WordPress Spam Protection

Step (3) − The Akismet plugin will be activated and then Click on Activate your Akismet account button as shown in the following screen.

WordPress Spam Protection

Step (4) − Click on Get your API key as seen in the following screen to get a new key or enter manually, if you already have API key.

WordPress Spam Protection

Step (5) − If you don't have API key then, click on GET AN AKISMET API KEY tab to move further.

WordPress Spam Protection

Step (6) − Fill up the required fields and click on Sign up button as shown in the following screen.

WordPress Spam Protection

Step (7) − Once you complete with signup process. You will get an API key in your registered e-mail id. Enter API key manually and click on Use this key button as seen in the following screen.

WordPress Spam Protection

Step (8) − If you have entered a correct API key, it will be verified and you will get a confirmation message as reflected in the following screen.

WordPress Spam Protection

Step (9) − Now your blog will be protected from spam by Akismet. You will be able to check the comments in your blog for spam, as well as manually mark comments as spam from the blog admin area → Comments.

WordPress Spam Protection

You can keep a track of how many spam posts have been stopped by Akismet and you can secure your posts, blogs, comments, etc. Furthermore, you can prevent your website from spammers, who can harm your site.


Backup & Restore

In this chapter, we will study how to Backup & Restore files and database in WordPress. In WordPress there are two parts of backing up such as −

WordPress Files Backup

To get the backup files of WordPress, you need to install FileZilla Client on your system.

Following are the simple steps used for files backup operation in WordPress −

Step (1) − Open the FileZilla Client as shown in the following screenshot.

WordPress Backup and Restore

Step (2) − Enter the Host, Username, Password and Port like you have used to log-in to your cPanel.

WordPress Backup and Restore

After filling all the fields, click on Quickconnect button.

Step (3) − You will get all files and folders of your WordPress site on the right side as seen in the following screen.

WordPress Backup and Restore

Step (4) − Select all the files and folders and right click on the mouse and click on Download.

WordPress Backup and Restore

After downloading the WordPress files from cPanel, it will be saved on your system.

WordPress Database Backup

Following are the simple steps for database backup in WordPress −

Step (1) − Type the path http://localhost/phpmyadmin in your browser. You will get the following screen.

WordPress Backup and Restore

Step (2) − Click on the database name ‘wordpress’ which you have created for WordPress.

WordPress Backup and Restore

Step (3) − After clicking on database wordpress, it will open the following page. Click on Export tab.

WordPress Backup and Restore

Step (4) − You will get two methods to export the database i.e. Quick and Custom. Select any one of the methods and click on Go button.

WordPress Backup and Restore

After exporting the database file, it will get saved on your system.

Restoring WordPress Files

Following are the simple steps used to restore the files in WordPress using ftp −

Step (1) − Open the FileZilla Client and login to your site using ftp as shown in the following screen.

WordPress Backup and Restore

Step (2) − Open the local directory in ftp and upload all WordPress files to your website as shown in the following screen.

WordPress Backup and Restore

Step (3) − Then, go to your wordpress folder → wp-config.php file. Copy and rename wp-config.php file before editing, in case of some mistake you can restore this file back.

Open the wp-config.php file and locate the following code.

define('DB_NAME', 'db_name');

Replace the db_name with your database name which you have created.

define('DB_USER', 'db_user');

Replace the db_user with your username of MySql.

define('DB_PASSWORD', 'db_password');

Replace the db_password with your password of MySql.

Save your wp-config file after editing and upload it to your WordPress site through ftp.

Restoring WordPress Database

Following are the steps used to restore the database in WordPress −

Step (1) − Type the path http://localhost/phpmyadmin in the browser. The following screen will pop up.

WordPress Backup and Restore

You can create a new database or import your backup in the existing database.

Here we'll create a new database name, i.e., new_wordpress and click on Create button.

Step (2) − You can view your created database as shown in the following screen. Click on the database name new_wordpress.

WordPress Backup and Restore

Step (3) − Click on Import.

WordPress Backup and Restore

Step (4) − Click on Choose File button to select the backup file from your system. After uploading the sql file, select format as SQL as shown in the following screen.

WordPress Backup and Restore

Click on Go button.

Step (5) − Once you click on Go, you will get a message after the sql file is uploaded successfully.

WordPress Backup and Restore

Optimization

In this chapter, we will study how to Optimize WordPress site.

Here are a few simple tips to optimize your WordPress site.

Ensure High Quality and Meaningful Content

Any page you create, the most important thing that matters is the content. You must have good content with keywords that can be helpful for users, not for the search engines. Content should be understandable and not complicated or difficult to read.

Have the right names for images

The names you choose for your images must be unique; consider choosing images keeping the user in mind. Use keywords that might be helpful for the users. Have some specific names for your images and don’t forget to add your alt tags and title tags to your images.

For example − If your image is about Chocolate sundae Ice-cream then do not mention the name as DSC12346, instead put it as ‘Chocolate-sundae-High-street-restaurant-new-york.jpg’. This would be much easier to search.

Use short permalinks that contain keywords

The permalinks you use must be understandable. For example − Use http://www.mywebsite.com/tutorialspoint/telangana/ instead of http://www.mywebsite.com/page-id?5631456325

Have optimized themes

Use those themes that are fast and are optimized for WordPress so that when applied to a website, it must not have low speed.

Sitemap should be in XML format

Google has many tools that can be useful. Tools like Website Optimizer, Webmaster Central, and Google XML sitemaps are very easy to use.

Connect posts to social media

Social media is a very important aspect today. So have them connected to your blog posts, pages, etc., to have good ranks and popularity. Help promote others posts and pages too and they will do the same in return.

Beware of black hat techniques

Don’t trick Google as it finds you in no time. Don’t put yourself in trouble and create problems for your site by using black hat techniques. Be sure to use genuine SEO techniques.

Delete your trash box

Always consider clearing your trash for more speed and to have a good flow with your website.

Keep checking your site statistics

Size of page matters a lot. The more images, flash, videos or media related posts on your page, the more it would be slower to load. Yslowi> module plugin is recommended to help you get a faster page browsing.

Check plugins

Having many plugins in WordPress may also be the reason for your page to slow load. So keep a check on your plugins which you’re working on. Consider checking your plugins before you add them.

Use CSS and JavaScript effectively

Always keep your CSS at the upper side of the page and JavaScript at the bottom. Let CSS load first and then JavaScript. Here is a plugin that will help you get your JavaScript’s at the bottom of the page. It is Footer javaScript.


Reset Password

In this chapter, we will learn how to reset your passwords in WordPress. We have two methods of resetting passwords in WordPress −

Let's look how to set password through the User section.

Step (1) − Login to your wordPress admin panel and click on Users → All Users from the dashboard.

WordPress Reset Password

Step (2) − When you click on All Users you get a page with a list of users. From this select the one you want to reset password of and click on edit.

WordPress Reset Password

When you click on edit, the following page gets displayed.

WordPress Reset Password

Now let's look into resetting your password using Lost your password section.

Step (3) − In this page you can type in your new password that must contain 7 characters. Once you are done with setting your new password click on Update Profile.

Step (3.1) − When you try logging into your WordPress admin panel, you forget your password and need to reset it, you get the following message on the page.

WordPress Reset Password

Step (3.2) − Click on Lost your password? The following page appears. Update your e-mail and say Get New Password.

WordPress Reset Password

Step (3.3) − After you click, you get a message saying a Link has been sent to the e-mail address you provided.

Step (3.4) − Go to your e-mail and open the (Wordpress Site) Password Reset mail and click on the link that is provided.

Step (3.5) − Type your new password, confirm again if required and then click on Reset Password.


Using Javascript

JavaScript will work within WordPress. If used within the template files, most JavaScript will work fine. Here are a few tips to make your JavaScript work in WordPress.

JavaScript in Template Files

To use JavaScript repeatedly within your site, you can either set the call for the JavaScript, or the script itself, in the head of your header.php template file, between the meta tags and the style sheet link, no differently than you would if you were using JavaScript in any HTML page. To "load" the JavaScript file into your site, in the head, add something like this:

<script type="text/javascript" src="/scripts/emailpage.js"></script>

Be sure that you define the type correctly, as your site will not validate without it.

In the spot where you wish to use the JavaScript, set the call for the JavaScript. For example, you are using a JavaScript that sets a link for users to "email this page" to a friend and you want it to be under the post title. It might look like this:

<h3 class="storytitle">
<a href="<?php the_permalink() ?>" rel="bookmark">
<?php the_title(); ?></a></h3>
<div class="emailpage">
<script type="text/javascript">
<!--
emailpage();
//--></script>
</div>

JavaScript in Posts

To use JavaScript inside of posts in WordPress, you need to take a few more steps. Odds are that this usage is for one or only a few instances, so adding the script to the header would only add code you don't need to your header.php template file.

For the occassional or one time use of JavaScript, you need to put the script into a JavaScript file and then call it out from within the post. Make sure that each script is defined by its function name such as:

function updatepage(){var m="Page updated "+document.lastMo.......}

To include a JavaScript inside a post, you need to combine both the call to the script file with the call to the JavaScript itself.

<script type="text/javascript" src="/scripts/updatepage.js"></script>
<script type="text/javascript">
<!--
updatepage();
//--></script>

Creating a Multiple Script File

You might have a collection of scripts that you call from time to time, like a scripts which calculate time zones or distance, or maybe scripts that create some effect or accent on your page. For reoccurring JavaScripts, consider grouping them together into one file.

Let's call our group JavaScripts file scriptfile.js (choose whatever you want) and say it contains the updatepage, emailpage, and caltimezone scripts. As you copy each JavaScript into the file, make sure it has a unique function name such as with this condensed version:

function updatepage() {var m="Page updated "+document.lastMo.......}
function emailpage() {mail_str = "mailto:?subject=....}
function caltimezone() {var timerID ; function tzone(tz, os, ds, cl) {this.ct =......} 

Place the script file of all the JavaScripts in the head of the header.php template file between the meta tags and the style sheet link. It will just sit there, loaded into the browser's memory, waiting for one of the scripts inside to be called.

<script type="text/javascript" src="/scripts/scriptfile.js"></script>

In the spot in your post where you would like to use the JavaScript, call it as follows:

<script type="text/javascript">
<!--
updatepage();
//--></script>

Troubleshooting JavaScript

If you are having trouble with including JavaScripts inside a post, use the Text Control Plugin which allows you to control on a global or per post basis the ability to turn off WordPress's automatic formatting features which can quickly turn a code into something readable instead of executable. Set the options on the post that you will be using the JavaScript on to have No Formatting or Markup or nl2br and No Character Formatting. You may have to experiment to get it to work. As a reminder, when using the Text Control Plugin, you must first Save and Continue Editing the post in order to see the Text Control Plugin options.

If you choose No Formatting, your post's text will all run together, so you will have to add paragraph tags and other HTML tags in order to format your page as WordPress normally does that for you.

If your JavaScript doesn't work, triple check that you haven't made any errors during the cut and paste into a group or single file. Be sure you used a text editor and not a word processing program to create the JavaScript file. Check the name of the function in the script file as well as on your site. Not all JavaScripts may work, and could possibly conflict with your PHP commands, but this is very rare.

If you are really having trouble with this, the WordPress Support Forum may be able to help.


Add Custom CSS to a Page or Post Without Plugins

First, you will need to add your custom CSS to a .css file. Preferrably in a child theme. In the following example, I added the custom CSS to home.css. Then, I used this snippet in my child theme’s functions.php file. You’ll need to change PAGE_ID to your actual page ID or page name.
function custom_style() {
	if ( is_page( 'PAGE_ID' ) ) {
		wp_enqueue_style( 'home', get_stylesheet_directory_uri() . '/home.css' );
	}
}
add_action( 'wp_enqueue_scripts', 'custom_style' );
Again, you can replace is_page() with your desired conditional tag. For posts, you can use is_single(). For a specific page template, you can use something like is_page_template( 'templates/about.php' ) and so on.

Page Templates

Page templates are a specific type of template file that can be applied to a specific page or groups of pages.

Note: As of WordPress 4.7 page templates support all post types. For more details how to set a page template to specific post types see example below.

Since a page template is a specific type of template file, here are some distinguishing features of page templates:

Uses for Page Templates

Page templates display your site’s dynamic content on a page, e.g., posts, news updates, calendar events, media files, etc. You may decide that you want your homepage to look a specific way, that is quite different to other parts of your site. Or, you may want to display a featured image that links to a post on one part of the page, have a list of latest posts elsewhere, and use a custom navigation. You can use page templates to achieve these things.

This section shows you how to build page templates that can be selected by your users through their admin screens.

For example, you can build page templates for:

Top ↑

Page Templates within the Template Hierarchy

When a person browses to your website, WordPress selects which template to use for rendering that page. As we learned earlier in the Template Hierarchy, WordPress looks for template files in the following order:

  1. Page Template — If the page has a custom template assigned, WordPress looks for that file and, if found, uses it.
  2. page-{slug}.php If no custom template has been assigned, WordPress looks for and uses a specialized template that contains the page’s slug.
  3. page-{id}.php If a specialized template that includes the page’s slug is not found, WordPress looks for and uses a specialized template named with the page’s ID.
  4. page.php If a specialized template that includes the page’s ID is not found, WordPress looks for and uses the theme’s default page template.
  5. singular.php If page.php is not found, WordPress looks for and uses the theme’s template used for a single post, irregardless of post type.
  6. index.php If no specific page templates are assigned or found, WordPress defaults back to using the theme’s index file to render pages.

Alert: There is also a WordPress-defined template named paged.php. It is not used for the page post-type but rather for displaying multiple pages of archives.

Top ↑

Page Templates Purpose & User Control

If you plan on making a custom page template for your theme, you should decide a couple of things before proceeding:

Every page template that has a template name can be selected by a user when they create or edit a page. The list of available templates can be found at Pages > Add New > Attributes > Template. Therefore, a WordPress user can choose any page template with a template name, which might not be your intention.

For example, if you want to have a specific template for your “About” page, it might not be appropriate to name that page template “About Template” as it would be globally available to all pages (i.e. the user could apply it to any page). Instead, create a single use template and WordPress will render the page with the appropriate template, whenever a user visits the “About” page.

Conversely, many themes include the ability to choose how many columns a page will have. Each of these options is a page template that is available globally. To give your WordPress users this global option, you will need to create page templates for each option and give each a template name.

Dictating whether a template is for global use vs. singular use is achieved by the way the file is named and whether or not is has a specific comment.

Note: Sometimes it is appropriate to have a template globally available even if it appears to be a single use case. When you’re creating themes for release, it can be hard to predict what a user will name their pages. Portfolio pages are a great example as not every WordPress user will name their portfolio the same thing or have the same page ID and yet they may want to use that template.

Top ↑

File Organization of Page Templates

As discussed in Organizing Theme Files, WordPress recognizes the subfolder page-templates. Therefore, it’s a good idea to store your global page templates in this folder to help keep them organized.

Alert: A specialized page template file (those created for only one time use) cannot be in a sub-folder, nor, if using a Child Theme, in the Parent Theme’s folder.

Top ↑

Creating Custom Page Templates for Global Use

Sometimes you’ll want a template that can be used globally by any page, or by multiple pages. Some developers will group their templates with a filename prefix, such as page_two-columns.php

Alert: Important! Do not use page- as a prefix, as WordPress will interpret the file as a specialized template, meant to apply to only one page on your site.

For information on theme file-naming conventions and filenames you cannot use, see reserved theme filenames.

Tip: A quick, safe method for creating a new page template is to make a copy of page.php and give the new file a distinct filename. That way, you start off with the HTML structure of your other pages and you can edit the new file as needed.

To create a global template, write an opening PHP comment at the top of the file that states the template’s name.

<?php /* Template Name: Example Template */ ?>

 

It’s a good idea to choose a name that describes what the template does as the name is visible to WordPress users when they are editing the page. For example, you could name your template Homepage, Blog, or Portfolio.

This example from the TwentyFourteen theme creates a page template called Full Width Page:

<?php
/**
 * Template Name: Full Width Page
 *
 * @package WordPress
 * @subpackage Twenty_Fourteen
 * @since Twenty Fourteen 1.0
 */

basics-page-templates-03Once you upload the file to your theme’s folder (e.g., page-templates), go to the Page > Edit screen in your admin dashboard.

On the right hand side under attributes you’ll see template. This is where users are able to access your global page templates.

Tip: The select list has a maximum width of 250px, so longer names may be cut off.

Top ↑

Creating a Custom Page Template for One Specific Page

As mentioned in the Template Hierarchy page, you can create a template for a specific page. To create a template for one specific page, copy your existing page.php file and rename it with your page’s slug or ID:

  1. page-{slug}.php
  2. page-{ID}.php

For example: Your About page has a slug of ‘about’ and an ID of 6. If your active theme’s folder has a file named page-about.php or page-6.php, then WordPress will automatically find and use that file to render the About page.

To be used, specialized page templates must be in your theme’s folder (i.e. /wp-content/themes/my-theme-name/ ).

Top ↑

Creating page templates for specific post types

By default, a custom page template will be available to the “page” post type.

To create a page template to specific post types, add a line under the template name with the post types you would like the template to support.

Example:

<?php 
/*
Template Name: Full-width layout
Template Post Type: post, page, event
*/ 
// Page code here...

Alert: This ability to add page templates to post types other than “page” post type is supported only from WordPress 4.7

When at least one template exists for a post type, the ‘Post Attributes’ meta box will be displayed in the back end, without the need to add post type support for ‘page-attributes’ or anything else. The ‘Post Attributes’ label can be customzied per post type using the ‘attributes’ label when registering a post type.

Backward Compatibility:

Let’s say you want to publicly release a theme with support for post type templates. WordPress versions before 4.7 will ignore the Template Post Type header and show the template in the list of page templates, even though it only works for regular posts. To prevent that, you can hook into the theme_page_templates filter to exclude it from the list. Here’s an example:

/**
 * Hides the custom post template for pages on WordPress 4.6 and older
 *
 * @param array $post_templates Array of page templates. Keys are filenames, values are translated names.
 * @return array Filtered array of page templates.
 */
function makewp_exclude_page_templates( $post_templates ) {
    if ( version_compare( $GLOBALS['wp_version'], '4.7', '&lt;' ) ) {
        unset( $post_templates['templates/my-full-width-post-template.php'] );
    }
 
    return $post_templates;
}
 
add_filter( 'theme_page_templates', 'makewp_exclude_page_templates' );

That way you can support custom post type templates in WordPress 4.7 and beyond while maintaining full backward compatibility.

Note that theme_page_templates is actually a dynamic theme_{$post_type}_templates filter. The dynamic portion of the hook name, $post_type, refers to the post type supported by the templates. E.g. you can hook into theme_product_templates to filter the list of templates for the product post type.

Top ↑

Using Conditional Tags in Page Templates

You can make smaller, page-specific changes with Conditional Tags in your theme’s page.php file. For instance, the below example code loads the file header-home.php for your front page, but loads another file (header-about.php) for your About page, and then applies the default header.php for all other pages.

if ( is_front_page() ) :
    get_header( 'home' );
elseif ( is_page( 'About' ) ) :
    get_header( 'about' );
else:
    get_header();
endif;

You can learn more about Conditional Tags here.

Top ↑

Identifying a Page Template

If your template uses the body_class() function, WordPress will print classes in the body tag for the post type class name (page), the page’s ID (page-id-{ID}), and the page template used. For the default page.php, the class name generated is page-template-default:

<body class="page page-id-6 page-template-default">

Note: A specialized template (page-{slug}.php or page-{ID}.php) also gets the page-template-default class rather than its own body class.

When using a custom page template, the class page-template will print, along with a class naming the specific template. For example, if your custom page template file is named as follows:

<?php
/* Template Name: My Custom Page */
?>

Then then rendered HTML generated will be as follows:

<body class="page page-id-6 page-template page-template-my-custom-page-php">

Notice the page-template-my-custom-page-php class that is applied to the body tag.

Top ↑

Page Template Functions

These built-in WordPress functions and methods can help you work with page templates: