Download as pdf or txt
Download as pdf or txt
You are on page 1of 83

SUCSD-RAJKOT MCA-3

Introduction Installation & Configuration

What is Content Management System (CMS)?

- A content management system (CMS) is a computer application that supports the creation
and modification of digital content.

- CMS is a software that facilitates creating, editing, organizing, and publishing content.

- Although it is mostly used for web publishing, it can be used to manage content on an
intranet, or in a single computer.

Introduction of Wordpress
- WordPress is a Content Management System, that allows you to create and publish your
content on the web.

- WordPress was initially released on 27th May, 2003 by Matt Mullenweg and Mike Little.

- WordPress was announced as open source in October 2009.

- WordPress allows users to have full control over the files, documents, as well as the design
and display of the content.

- WordPress is being used in all sort of creative ways. We have seen WordPress being used to
power small business websites, internal communication system for companies, web
directories, movie databases, application infrastructure base, arcade sites, and basically
anything else you can think of.

Prepared By:Mr.Ronak J. Goda 1


SUCSD-RAJKOT MCA-3

Features of Wordpress
- User Management

It allows managing the user information such as changing the role of the users to
(subscriber, contributor, author, editor or administrator), create or delete the user,
change the password and user information. The main role of the user manager is
Authentication

- Media Management

It is the tool for managing the media files and folder, in which you can easily upload,
organize and manage the media files on your website.

- Theme System

It allows modifying the site view and functionality. It includes images, stylesheet,
template files and custom pages.

- Extend with Plugins

Several plugins are available which provides custom functions and features according to
the users need.

- Search Engine Optimization

It provides several search engine optimization (SEO) tools which makes on-site SEO
simple.

- Multilingual

It allows translating the entire content into the language preferred by the user

- Importers

It allows importing data in the form of posts. It imports custom files, comments, post
pages and tags.

Prepared By:Mr.Ronak J. Goda 2


SUCSD-RAJKOT MCA-3

Advantages
- It is an open source platform and available for free.

- CSS files can be modified according to the design as per users need.

- There are many plugins and templates available for free. Users can customize the various
plugins as per their need.

- It is very easy to edit the content as it uses WYSIWYG editor (What You See Is What You
Get is a user interface that allows the user to directly manipulate the layout of document
without having a layout command).

- Media files can be uploaded easily and quickly.

- It offers several SEO tools which makes on-site SEO simple.

- Customization is easy according to the user's needs.

- It allows creating different roles for users for website such as admin, author, editor and
contributor.

Disadvantages
- Using several plugins can make the website heavy to load and run.

- PHP knowledge is required to make modifications or changes in the WordPress website.

- Sometimes software needs to be updated to keep the WordPress up-to-date with the
current browsers and mobile devices.

- Updating WordPress version leads to loss of data, so it a backup copy of the website is
required.

- Modifying and formatting the graphic images and tables is difficult.

Prepared By:Mr.Ronak J. Goda 3


SUCSD-RAJKOT MCA-3

Installation of wordpress

System Requirements for WordPress


Web Server:

- WAMP (Windows)
- LAMP (Linux)
- XAMP (Multi-platform)
- MAMP (Macintosh)

Operating System

- Windows operating system

Browser Support

- IE (Internet Explorer 8+)


- Firefox
- Google chrome
- Safari
- Opera

PHP Compatibility

- PHP 5.2+

Prepared By:Mr.Ronak J. Goda 4


SUCSD-RAJKOT MCA-3

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

Download the WordPress zip file from the official site.

Create Store Database


- WordPress requires MySQL database. So create a new empty database with
user/password (for example, user as "root" and password as "root" or else you can set as
per your convenience).

- Then, you can continue with the installation process as discussed further.

Prepared By:Mr.Ronak J. Goda 5


SUCSD-RAJKOT MCA-3

Setup 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 fi e 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.

Prepared By:Mr.Ronak J. Goda 6


SUCSD-RAJKOT MCA-3

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

Read all instruction then click on Let‟s Go button.

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

Prepared By:Mr.Ronak J. Goda 7


SUCSD-RAJKOT MCA-3

Database Name: Enter the database name which you have created in MySQL database for
WordPress.

Username: Enter the user name of your MySQL database.

Password: Enter the password which you had set for MySQL database.

Database Host: Write the host name, by default it will be localhost.

Table Prefix: It is used to add prefix in the database tables which helps to run multiple sites on
the same database. It takes the default value.

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 to run

Prepared By:Mr.Ronak J. Goda 8


SUCSD-RAJKOT MCA-3

Step (6): Enter administrative information.

It contains the following fields:

Site Title: Enter the name of the site which you are going to create in WordPress.

Username: Enter the username as per your choice while logging in the WordPress.

Password twice: Enter password two times to protect your site.

Your E-mail: Enter your e-mail address which helps to recover the password or any
update.

Privacy: It allows the search engine to index this site after checking the checkbox.

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

Prepared By:Mr.Ronak J. Goda 9


SUCSD-RAJKOT MCA-3

Step (7): 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.

Prepared By : Mr.Ronak J. Goda 10


SUCSD-RAJKOT MCA-3

Wordpress Directory & file structure.


- The directory structure is the organization of files into a hierarchy of folders. It describes
how files are arranged for an application. A hierarchy is similar to a tree structure.

The WordPress Directory Structure


- The core WordPress files and directories are listed below.

wp-admin
wp-content
wp-includes
index.php
license.txt
readme.html
wp-activate.php
wp-blog-header.php
wp-comments-post.php
wp-config-sample.php
wp-cron.php
wp-links-opml.php
wp-load.php
wp-login.php
wp-mail.php
wp-settings.php
wp-signup.php
wp-trackback.php
xmlrpc.php
.htaccess
wp-config.php

- These are the core WordPress directories and files. Now, let‟s see some of the important
files and folders in detail. Keep in mind that the first three are folders and rest are files.

wp-admin
- The admin tools are powered by this folder. As it‟s name indicates, this deals with the
administrator. The main file inside this directory is the admin.php. It enables the
connection to the database, displays the WordPress dashboard, and performs any other

Prepared By : Mr.Ronak J. Goda 11


SUCSD-RAJKOT MCA-3

number of key functions, such as checking if any given user is in fact the admin in
question.

wp-content
- The next folder we are going to see is the wp-content. The Themes and Plugins are
familiar to every WordPress user. These are stored inside this directory.

Plugin
- The plugins are used to add more functionality to the WordPress site. Plugins can offer
custom setup to the WordPress installation while the default WordPress installation is
designed to be light weight.

Themes
- The WordPress themes provide the graphical interface to the website. There are many
files that work together to achieve this.

- The themes and plugins are the major parts in the wp-content directory.

wp-includes
- The wp-includes is the final top-level folder and is large in size. As we have seen earlier,
the wp-admin includes all the files necessary to power said admin functions, wp-content
stores all your themes and plugins, and wp-includes is what enables the site to run.

- This folder is where most of the WordPress core files are stored. A fresh WordPress
install will include over 140 different files in the main directory, and fourteen different
folders including certificates, fonts, js, theme-compact, and widgets.

- These subfolders aren‟t important as the files included in the main folder, such as
functions.php. This file is part of WordPress‟ core, and it comes with a lot of the functions
that enable the WordPress installation to work. As an example, some lines of code will be

Prepared By : Mr.Ronak J. Goda 12


SUCSD-RAJKOT MCA-3

seen when you open the file on a text editor, and they‟re just a regular function meant to
transform dates into different formats.

index.php
- The index file loads and initializes all your WordPress files when a page is requested by a
user.

license.txt
- This is WordPress license file. The WordPress is a free software and is licensed under the
GNU General Public License as published by the Free Software Foundation.

readme.html
- This core file contains the instructions to the user as its name indicates.

wp-activate.php
- This contains the following:

do_activate_header()

o Function: Adds an action hook specific to this page that fires on wp_head.

activate_wp_head

o Fires before the Site Activation page is loaded, but on the wp_head action.

wpmu_activate_stylesheet()

o Function: Loads styles specific to this page.

activate_header

o Action Hook: Fires before the Site Activation page is loaded.

wp-blog-header.php
- This folder contains the http headers.

Prepared By : Mr.Ronak J. Goda 13


SUCSD-RAJKOT MCA-3

xmlrpc.php
- WordPress uses an XML-RPC interface. WordPress has its own implementation for
WordPress-specific functionality in an API called the WordPress API. This should be used
when possible, and your client should use the API variants beginning with the wp prefix.

- XML-RPC functionality is turned on by default since WordPress 3.5.

- In previous versions of WordPress, XML-RPC was user enabled. To enable, go to Settings


> Writing > Remote Publishing and check the box.

wp-config.php
- It is one of the core WordPress files which contains information about the database,
including the name, host (typically localhost), username, and password.

There are many other folders and files, but these are the most important folders and files in the
WordPress directory structure.

Prepared By : Mr.Ronak J. Goda 14


SUCSD-RAJKOT MCA-3

Dashboard overview

Admin Bar
The Admin Bar is the dark gray menu bar that appears across the top of the dashboard. It
also appears across the top of the site itself, when you are logged in. However it is not visible to
public visitors to the site.

WordPress Icon

In the very top left location of the admin bar, you will see the WordPress icon. When you hover
over this icon, a dynamic menu with four links appears:

- WordPress.org links to the main WordPress site, which contains downloads and
documentation for the WordPress application.

- Documentation links to the WordPress Codex, which is the official documentation for
WordPress.

- Support Forums links to the support area of WordPress.org.

- Feedback links to the support forum on WordPress.org that is dedicated to requests and
feedback.

Prepared By : Mr.Ronak J. Goda 15


SUCSD-RAJKOT MCA-3

Home Icon

- The next icon on the admin bar is the home icon for your site.

- Clicking this link takes you to the public-facing home page of your site.

- Once you are there, the link in this position takes you back to the Dashboard.

- It‟s a toggle. You might find it useful to have the Dashboard and your main site each open
in separate browser tabs, so that you can quickly switch back and forth.

Notification Icons
- There are two notification icons that can appear in the Admin Bar.

- Comments is always visible.

- If there are comments pending on your site, this icon changes color and the number of
comments is displayed next to the icon.

- Clicking the icon takes you to the Comments page.

- There is also an Updates icon, that appears when there are updates available to your
plugins, themes or the WordPress core files.

- Clicking this icon takes you to the Updates page.

- Hovering over New brings up a menu of links to create new items such as Pages, Posts or
Media items.

- The actual contents of this list depends on your user role. For example, if your role
doesn‟t allow you to create new users, you won‟t see users in this menu. Some plugins
also add items to this menu.

Prepared By : Mr.Ronak J. Goda 16


SUCSD-RAJKOT MCA-3

- Note that this menu duplicates some of the links on the sidebar menu, which we‟ll get to
in a few minutes.

User Name and Avatar

- In the far right corner of the admin bar, you will see your user name and avatar.

- From this menu, clicking on either your name or “Edit My Profile” will take you to the
Edit Profile page. Clicking on Log Out will, well, log you out.

- Just below the dark grey Admin Bar are two tabs: the Screen Options tab and the Help
tab.

Screen Options Tab

- The Screen Options tab appears on most administrative pages and it allows you to
control the elements that appear on the page.

- These are the elements that appear to you. When other people log in to the Dashboard,
they will see the selections that they have chosen.

- Click the Screen Options tab and you‟ll see a list of the administrative widgets that are
available on that page.

- Each widget has a checkbox to control its display on that page. [Demonstrate checking
and unchecking boxes].

- Different pages will have different selections and some pages, like the Editor, have a lot
more than this.

- It is common for a screen to be missing information (for example, post excerpt section is
simply not showing.) This can be a frustrating experience and the screen options tab can
be the solution.

Prepared By : Mr.Ronak J. Goda 17


SUCSD-RAJKOT MCA-3

Help Tab

- The Help tab, also located directly below the dark grey admin bar, contains information
about the current page [open Help].

- In this case, it gives you an overview, information about the left-hand navigation menu,
how to control the page layout and the content that you see on the page.

Each page in the admin area will display relevant information under its Help tab

Prepared By : Mr.Ronak J. Goda 18


SUCSD-RAJKOT MCA-3

Page Body

In the body of the Dashboard, you‟ll find a number of administrative widgets or panels. You‟ve
seen how these can be shown and hidden using the checkboxes in the Screen Options tab. Their
position can also be changed, simply by dragging and dropping them. [Demonstrate dragging
and dropping.]

There are a number of widgets here that are included when WordPress is installed, including:

 At A Glance. This widget gives you some quick totals for the number of pages, posts and
comments that are currently on your site. It also displays the current theme and will note
if search engines are discouraged from indexing the site.
 Quick Draft. Anything entered into this form will be saved as a draft post. That is, it will
be saved but not be published on the site. A list of links to currently saved drafts is shown
underneath this form. This is handy for jotting down quick ideas for posts that you want
to come back and finish later.
 Activity. Activity shows your most recent posts and comments, linked to their respective
editors.
 Widgets added by plugins. Some plugins add their own administrative widgets. These
can be selected in the Screen Options tab and dragged and dropped, just like those that
are installed by WordPress.

Prepared By : Mr.Ronak J. Goda 19


SUCSD-RAJKOT MCA-3

Left Sidebar
- The most common way of moving around in the admin area is by using the navigation
links in the left sidebar. Some of these are used much more frequently than others,
particularly posts, pages and comments.

- When there are sub-menu items, they are displayed in dynamic fly-out menus
[demonstrate] and after you‟ve clicked on a menu item with sub-menus, the submenus
will be displayed in the sidebar [demonstrate with Posts]. As you can see, these are the
sub-menu items available under Posts.

- The menu items in the sidebar will vary, depending on the role assigned to you as a user.
For instance, a user with the role of Author wouldn‟t see any of the menu items that are
unrelated to editing posts and pages. Users with the role of Admin will see everything
available for the site.

- Plugins also add items to this menu, in positions that are controlled by the plugin author.

Prepared By: Mr.Ronak J. Goda 20


SUCSD-RAJKOT MCA-3

Posts List
- WordPress displays many different collections of items in tabular format.

- Plugin authors are urged to display information in this format but some choose not to,
which can be confusing.

- Open and look at the Posts list page. [open posts if not already open]. When you click on
the title of a post, it will open in the editor.

- However, notice that when you roll the mouse pointer over the title of a post, additional
links appear below the title.

- These include Edit (same as clicking on the title), Quick Edit, Trash and View. Some

- plugins add more links here as well.

Prepared By: Mr.Ronak J. Goda 21


SUCSD-RAJKOT MCA-3

 Quick Edit allows you to change much of the meta information about the post, without
opening it in the editor. You can quickly change the post‟s categories, tags and several
other items that you‟ll learn more about later.
 Trash moves the post to the trash folder. You can recover anything that you have put
into the trash for up 30 days, unless you have intentionally deleted it or unless your
WordPress install has designated a different length of time.
 View links to the publicly visible post on the site.

- You can use the checkboxes next to the titles to perform actions on multiple items. After
checking one or more boxes [check some boxes], the Bulk Actions drop-down shows you
the actions that can be performed. [Click drop-down] As you can see, the actions here
are Edit and Move to Trash.

- If you select Edit and click Apply, you‟ll see the same menu that we did earlier for Quick
Edit. Except now, any changes will be applied to all of the items with checked boxes,
when the Update button is clicked. Be careful, you can change a lot of things with one
click [click Cancel].

- Selecting Move to Trash and clicking Apply moves all of the checked posts to the trash
folder.

- The links above the table will filter the list of posts to show All, Published, Drafts and
Trash. [Move something to the Trash, if there‟s nothing there already] When looking at
the list of posts in the Trash, the rollover links include Restore and Delete Permanently
[demonstrate Restore].

- You can also filter the list of posts by dates (month and year) or categories [click drop-
downs to demonstrate].

- The pagination control allows you to step through the list of items one page at a time.

- Lastly, you can search for words or phrases that may be contained in your posts. Any
posts that contain the search words will be displayed.

Prepared By: Mr.Ronak J. Goda 22


SUCSD-RAJKOT MCA-3

Pages List
- The pages list is similar to the Posts list but has fewer columns.
- This reflects the simpler nature of pages vs. posts.
- The roll-over behavior remains the same, when you move the mouse pointer over a page
title.
- There is still a bulk actions drop-down with the same options that you saw in the Posts
list

Prepared By: Mr.Ronak J. Goda 23


SUCSD-RAJKOT MCA-3

Media Library
- The Media Library can display items in a grid view, as thumbnails only, or a list view,
which is more like the Page and Post lists that you just saw.

- The only bulk action for Media Library items are Delete permanently, which is pretty
self- explanatory.

- A column that‟s unique to the Media Library is uploaded to. This tells you on which page
or post a particular item is being used. This column may be blank if the item was
uploaded directly to the Library and not attached to a page or post.

Tools and Settings


- The left hand sidebar will also have sections called “Tools” and “Settings”.

- The content of these sections is dependent upon the user role and also the plugins
that may be installed on the site.

Prepared By: Mr.Ronak J. Goda 24


SUCSD-RAJKOT MCA-3

How to add, edit and delete page, category, post, tag


Add Page

- To get started adding a new page to your WordPress site, find the Pages menu in the
WordPress Dashboard Navigation menu. Click Add new.

- The WordPress page editor looks nearly identical to the post editor, except for a few
different boxes located on the right side of the screen.

- Add the title of the page, like about. Note: If you have pretty permalinks set up, the title
of your page will also be the URL slug.

- Next, add some content.

- The Publish section of the page editor is exactly the same as for writing posts. When
you‟re ready to publish, you can either publish immediately, save this or a draft, or
schedule the page to be published later.

- The Page Attributes section applies a parent page and template to your new page. For
the Parent section, you can arrange your pages into hierarchies. For example, you could
create this new page with additional pages under it. There are no limits to how many
levels you can nest pages.

- Some WordPress themes have custom page templates, so the next Template section
allows you to apply a template to your new page.

- The Order box allows you to order your page numerically. Pages are usually ordered
alphabetically, but you can choose your own order by entering a number in this field.

- Preview the page one last time, then click Publish. You‟ve added a new page to your
WordPress site.

Prepared By: Mr.Ronak J. Goda 25


SUCSD-RAJKOT MCA-3

Edit Page
- Open page which you want to edit.

- Now you can edit in the page like name, slug, content, publish date etc.

- Then click on update for implement in pages.

Delete Page

- To delete a web click on menu or hover over the one you wish to delete.

- On the hover menu, you will see a Trash option. Click this to move the page to the trash.
(Note that the file is just moved to the trash and is not actually deleted. You can go into
the trash folder to restore a page if you accidentally delete a page.)

- To get to the trash folder go to the Pages section depending upon what you want to
delete.

- Hover over the page you want to delete and click on the Delete Permanently link.

- You can also check the box prior to multiple pages and use the “Bulk Action” drop-down
box to Permanently Delete multiple pages at once.

Add Category

- Go to Posts in Categories page and add your new category.

- This method is particularly useful, if you want to create all your categories before adding
content.

Edit Category

- Go to Posts > Categories.

- Find the category name you wish to change and click Edit.

- Change the category name.

Prepared By: Mr.Ronak J. Goda 26


SUCSD-RAJKOT MCA-3

- Change the category Slug, the permalink “nice” name for the category.

- Add or change the category description.

- Click Update

Delete Category

- Click on Posts -> Categories in WordPress

- You can delete Category, When the cursor hovers on the Categories, a few options get
displayed

- below the Category name. Click on Delete button

- When you click on delete, you will get a pop message asking for confirmation to delete
the particular category

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

Add post

- Click the 'Posts' tab.

- Click the 'Add New' sub-tab.

- Start filling in the blanks: enter your post title in the upper field, and enter your post
body content in the main post editing box below it.

- As needed, select a category, add tags, and make other selections from the sections
below the post.

- When you are ready, click Publish.

Prepared By: Mr.Ronak J. Goda 27


SUCSD-RAJKOT MCA-3

Edit Post

- Click on the post‟s title to view the edit page.

- Make your changes to the post as needed.

- Once you‟re finished, click the Update button to save your edited post.

- Your update is saved.

Delete Post

- Click on Posts -> All Posts in WordPress.

- You can view Post.

- When the cursor hovers on the Post, few options get displayed below the Post name.

- Click on Edit option

- You can edit or change the content or title of the post as per your needs, and then click
on Update button

Add tag

- To add tags to a new post, go to admin area > Posts > Add New.

- When you write your new post, you can add a tag to it by typing the tag word in the
Tags field on the right and clicking the Add button.

- You can add as many tags as you want.

- Then click on update button.

Prepared By: Mr.Ronak J. Goda 28


SUCSD-RAJKOT MCA-3

Edit tag

- Go to the tags.

- Hover on the tag and you can see some option.

- Select the edit tag

- You can edit you want to edit tag.

- Then click on update.

Delete tag

- Select each tag you want to delete using the checkbox to the left of the tag name.

- If you want to select all tags click the checkbox at the top: From the bulk actions menu

- select Delete

- click Apply.

- The tags will be deleted.

Add new media file (image, pdf, doc etc.) & attach to post or page.
Add media in post

- Click on Posts --> Add New in WordPress.

- Click on Add Media.

- You can select the files from the Media Library tab.

- You can insert an image directly from your system by clicking on Upload Files tab.

Prepared By: Mr.Ronak J. Goda 29


SUCSD-RAJKOT MCA-3

- Click on Insert into Post button.

Add media in page

- Click on page --> Add New in WordPress.

- Click on Add Media.

- You can select the files from the Media Library tab.

- You can insert an image directly from your system by clicking on Upload Files tab.

- Click on Insert into page button.

User Roles and Capabilities.


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:

Administrator
The Administrator has all the rights. An Admin can do anything and everything on the
WordPress site such as creating more admin, inviting more users and also removing them.

Editor
The Editor has access to all the posts, pages, comments, categories, tags and links. They
can create, publish, edit or delete any posts or pages.

Author
The Author can only write posts, upload pictures, edit, and publish their own posts.

Contributor
The Contributor can only write and edit their posts until published. They can create their
own posts and pages but cannot publish them. They cannot upload images or files but can see
your site's status. When they want to publish any post, it must be first notified personally to the

Prepared By : Mr.Ronak J. Goda 30


SUCSD-RAJKOT MCA-3

administrator for review. When the post is approved, the contributor cannot make any changes
once published.
Follower
The Follower can only read and comment on the posts. Followers are the ones who have
signed in to your account to receive updates.

Viewer
Viewers can only view your posts; they cannot edit but can only comment on the posts.

Setting (General, writing, Reading, Discussion, Media, Permalinks)

General: Click on Settings -> General option in WordPress.

Following are the details of the fields on general settings page


- Site Title: It displays the name of the site in the template header.

- Tagline: Displays a short sentence about your site.

- WordPress Address (URL): It is the URL of WordPress directory where your all core
application files are present.

- Site Address (URL): Enter the site URL which you want your site to display on the
browser.

- E-mail Address: Enter your e-mail address which helps to recover your password or any
update.

- Membership: Anyone can register an account on your site after you check this checkbox.

- New User Default Role: The default role is set for the newly registered user or members.

- Timezone: Sets the time zone based on the particular city.

- Date Format: Sets the date format as you need to display on the site.

Prepared By : Mr.Ronak J. Goda 31


SUCSD-RAJKOT MCA-3

- Time Format: Sets the time format as you need to display on the site.

- Week Starts On: Select the week day which you prefer to start for WordPress calendar.
By default it is set as Monday.

- Site Language: Sets the language for the WordPress dashboard.

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

Writing: To change writing settings, go to Settings -> Writing option.

Following are the details of the fields on the page.


- Formatting : This field defines two sub options for better user experience.
o The first option Convert emoticons like :-) and :-P to graphics on display will turn
text-based emoticons into graphic-based emoticons.
o The second option WordPress should correct invalidly nested XHTML
automatically corrects the invalid XHTML placed within the posts or pages.

- Default Post Category: It is a category to be applied to a post and you can leave it as
Uncategorized.

- Post via e-mail: This option uses e-mail address to create posts and publishes posts on
your blog through e-mail. To use this, you'll need to set up a secret email account with a
POP3 access, and any mail received at this address will be posted.

- Mail Server: It allows reading the e-mails that you send to WordPress and stores them
for retrieval. For this, you need to have POP3 compatible mail server and it will have URI
address such as mail.example.com, which you should enter here.

- Login Name: To create posts, WordPress will need its own e-mail account. The Login
Name will use this e-mail address and should be kept as a secret as spammers will post
links redirecting to their own websites.

- Password: Set password for the above e-mail address.

Prepared By : Mr.Ronak J. Goda 32


SUCSD-RAJKOT MCA-3

- Default Mail Category: It allows selecting custom category for all the posts that are
published via Post by e-mail feature.

- Update Services: When you publish a new post, WordPress will automatically notify the
site update services in the box. See the Update Services on the codex for the long list of
possible services.

- After filling all the above information, click on Save Changes button to save your
information.

Reading: Click on Settings -> Reading option in WordPress.

Following are the details of the fields on reading settings.

- Front page displays: This section is used to display the front page in any of the following
format:
o Your latest posts: It displays latest posts on the front page.
o A static page: It displays the static pages on the front page.
- Front Page: You can select the actual page you want to display on front page from the
drop down.

- Posts Page: You can select the page from the drop down which contains posts.

- Blog pages show at most: The number of posts to be displayed per page or site. By
default, it is set as 10.

- Syndication feeds show the most recent: The user can view the number of posts when
they download one of the site feeds. By default, it is set as 10.

- For each article in a feed, show: This section is used to display the post by selecting any
of the following formats:

o Full Text: It displays the complete post. It is set as default.


o Summary: It displays the summary of the post.
- Search Engine Visibility: After clicking on the checkbox, Discourage search engines from
indexing this site, your site will be ignored by the search engine.

Prepared By : Mr.Ronak J. Goda 33


SUCSD-RAJKOT MCA-3

- After filling all the information, click on Save Changes button to save your Reading
Setting information.

Discussion: Click on Settings -> Discussion option in WordPress.

Following fields are seen in Discussion settings.

- Default article settings: These settings are default to the new pages you create or new
posts. This contains three more settings. They are:
o Attempt to notify any blogs linked to from the article: When you publish articles
then it sends a notification (sends pings and trackback) to other blogs.
o Allow link notifications from other blogs (pingbacks and trackbacks): Accepts pings
from other blogs.
o Allow people to post comments on new articles: You can allow or disallow other
people to comment on your article using this setting.

- You can change the settings as per your will for individual articles
- Other Comment Settings: This setting has the following options:
o Comment author must fill out name and e-mail: When you check this box, it is
mandatory for visitors to fill their name and email address.
o Users must be registered and logged in to comment: If you check this box, only
those registered visitors can leave comments, if not checked anyone can leave any
number of comments.
o Automatically close comments on articles older than days: This option allows you
to accept comments only for a particular time period as per your wish.
o Enable threaded (nested) comments: When you check this option, visitors can
reply or have a discussion and get responses.
o Break comments into pages with top level comments per page and the page
displayed by default: If your pages are getting a lot of comments then you can
split them into different pages by checking this box.
o Comments should be displayed with the comments at the top of each page: You
can arrange the comments in the form of ascending or descending order.

- Email me whenever: This setting contains two options, namely


o Anyone posts a comment: When you check into this box, the author gets an e-
mail for every single comment that is posted.

Prepared By : Mr.Ronak J. Goda 34


SUCSD-RAJKOT MCA-3

o A comment is held for moderation: This is used in case you do not want your
comment to be updated before it's moderated by the admin.

- Before a comment appears: This setting allows how your posts are controlled.
There are two more settings as followed:
o Comment must be manually approved: If you check this box then only the
approved comments by the admin can be displayed on the posts or pages.
o Comment author must have a previously approved comment: This can be
checked when you want to approve a comment of an author whose has
commented and his e-mail address matches the e-mail address of the previous
posted comment. Otherwise the comment is held for moderation
- Comment Moderation: Contain only a specific number of links that are allowed into a
comment.

- Comment Blacklist: You can input your own spam words which you do not want your
visitors to enter into the comments, URL, e-mail etc.; later it would filter the comments.

- Avatars: Avatar is a small image that displays at the top-right-hand corner of the
dashboard screen beside your name. It is like your profile picture. Here you have a few
more options where you can set your avatar for WordPress site.
o Avatar Display: It displays your avatar besides your name when it is
Checked
o Maximum rating: You have a four other options of avatars you can use.
They are G, PG, R and X. This is the age section where you select according
to which type of audience you want to display your posts.
o Default Avatar: In this option, there are few more types of avatars with images
you can keep these avatars according to your visitors e-mail address.

- Click on Save Changes button to save the changes.

Prepared By : Mr.Ronak J. Goda 35


SUCSD-RAJKOT MCA-3

Media : Click on Settings->Media option in WordPress.

Following are the details of the fields on Media settings:


- Thumbnail size: Set the size of the thumbnail.

- Medium size: Set the height and width of medium size images.

- Large size: Set width and height of larger images.

- Uploading files: After checking this checkbox, the uploaded image will be arranged into
year and month based folder.

After setting the dimension in pixels, click on Save Changes button. It saves
your media setting information.

Permalink: Click on Settings-> Permalinks option from the left navigation menu.

Here are a few settings you can make:


Common settings
- Check any of the radio buttons to choose your permalink structure for your blogs
o Default: It sets the default URL structure in WordPress.
o Day and name: It sets URL structure according to the date and name in your posts.
o Month and name: It sets the URL structure according to the month and name in
your post.
o Numeric: It sets numbers in the URL structure in your post.
o Post name: It sets post name in the URL structure in your post.
o Custom Structure: It sets the URL structure of your choice by writing the desired
name in the given text box.
- Once you are done with changes, click on Save Changes button to save the permalink
settings.

Prepared By : Mr.Ronak J. Goda 36


SUCSD-RAJKOT MCA-3

Updating wordpress
One-click Update

- Modern versions of WordPress let you update with the click of a button. (This feature
was added in 2.7, so if you are using an older version, you will need to follow the steps to
update manually.)

- Going to the Dashboard > Updates screen. Once you are on the "Update WordPress"
page, click the button "Update Now" to start the process off.

- You shouldn't need to do anything else and, once it's finished, you will be up-to-date.

- One-click updates work on most servers. If you have any problems, it is probably related
to permissions issues on the filesystem.

Manual Update

Step 1: Replace WordPress files

- Get the latest WordPress zip (or tar.gz) file.

- Unpack the zip file that you downloaded.

- Deactivate plugins.

- Delete the old wp-includes and wp-admin directories on your web host (through your
FTP or shell access).

- Using FTP or your shell access, upload the new wp-includes and wp-admin
directories to your web host, in place of the previously deleted directories.

- Upload the individual files from the new wp-content folder to your existing wp-content
folder, overwriting existing files. Do NOT delete your existing wp-content folder. Do NOT
delete any files or folders in your existing wp-content directory (except for the one being
overwritten by new files).

Prepared By : Mr.Ronak J. Goda 37


SUCSD-RAJKOT MCA-3

- Upload all new loose files from the root directory of the new version to your existing
WordPress root directory.

- NOTE - you should replace all the old WordPress files with the new ones in the wp-
includes and wp-admin directories and sub-directories, and in the root directory (such as
index.php, wp-login.php and so on). Don't worry - your wp-config.php will be safe.

- Be careful when you come to copying the wp-content directory. You should make sure
that you only copy the files from inside this directory, rather than replacing your entire
wp-content directory. This is where your themes and plugins live, so you will want to
keep them. If you have customized the default or classic themes without renaming them,
make sure not to overwrite those files, otherwise you will lose your changes. (Though
you might want to compare them for new features or fixes..)

- Lastly you should take a look at the wp-config-sample.php file, to see if any new settings
have been introduced that you might want to add to your own wp-config.php.

Step 2: Update your installation

- Visit your main WordPress admin page at /wp-admin.

- You may be asked to login again.

- If a database upgrade is necessary at this point, WordPress will detect it and give you a
link to a URL like http://example.com/wordpress/wp-admin/upgrade.php. Follow that
link and follow the instructions.

- This will update your database to be compatible with the latest code. You should do this
as soon as possible after step 1.

- Don't forget to reactivate plugins!

Prepared By : Mr.Ronak J. Goda 38


SUCSD-RAJKOT MCA-3

Database Structure
- WordPress uses a range of database tables with relationships between them to
minimize the amount of data that has to be stored - this creates one-to-many
relationships.

- This means that, say, one user can have many posts that they authored related to their
user record.

- It saves space - if WordPress stored all of the user data for each users against every post
their authored that would mean a lot of repeated data and a lot of space.

- The diagram below is taken from the WordPress codex and shows the database tables
and how they are linked:

Prepared By : Mr.Ronak J. Goda 39


SUCSD-RAJKOT MCA-3

Prepared By : Mr.Ronak J. Goda 40


SUCSD-RAJKOT MCA-3

- Most of the tables are linked to one or more other tables via one field.

- This field will be a unique identifier for each record such as post_id.

- This is shown in more detail in this table:

Table Data stored Linked to

wp_postmeta (via post_i


Posts, pages, attachments,
d)
wp_posts revisions and navigation menu
wp_term_relationships(
items
via post_id)

wp_postmeta Metadata for each post wp_posts (via post_id)

wp_comments Comments wp_posts (via post_id)

wp_commentmeta
wp_comments (via commen
Metadata for each comment
t_id)

wp_posts (via post_id)


wp_term_relationships
Relationships between posts
wp_term_taxonomy (via t
and taxonomies
erm_taxonomy_id)

wp_term_taxonomy
Taxonomies (including wp_term_relationships (
categories and tags) via term_taxonomy_id)

Your categories and tags and


wp_terms
wp_term_taxonomy (via t
the terms assigned to custom
erm_id)
taxonomies

wp_links
The links in your blogroll (if you wp_term_relationships (
still have one) via link_id)

Prepared By : Mr.Ronak J. Goda 40


SUCSD-RAJKOT MCA-3

Table Data stored Linked to

wp_users
wp_posts (via post_auth
Users
or)

wp_user_meta Metadata for each user wp_users (via user_id)

Site settings and options (set


wp_options via the Settings screens and via n/a
plugins and themes)

A few things are worth noting:

- Database tables have the wp_ prefix by default. You can change this when you configure
your site but there isn't much value to it.

- The core table is the wp_posts table, where most of your data will be stored. This holds
(almost) everything else together.

- Only one table isn't attached to any others - the wp_options table. This tables stores data
about the site and the WordPress installation, which isn't related to data about posts or
users.

- Two tables are used to store data about taxonomies - these will be explained in more
detail later in this series.

- The wp_users and wp_comments tables are not linked - although it is possible to specify
that users have to be registered to comment, WordPress doesn't actually store data
about comments against each user who has posted them.

- A multisite installation will have some extra tables. I haven't included those here as that's
outside the scope of this tutorial.

Prepared By : Mr.Ronak J. Goda 41


SUCSD-RAJKOT MCA-3

Linking Content to Database Tables

Having looked at the content types in WordPress and the database tables used to store them, it
can be helpful to match the two up. The table below shows which database table is used to
store each type of content.

Content Type Table(s)

Posts wp_posts

Pages wp_posts

custom post types wp_posts

Attachments wp_posts

Links wp_links

navigation menu items wp_posts

Categories wp_terms

Tags wp_terms

custom taxonomies wp_term_taxonomy

taxonomy terms wp_terms

post metadata wp_post_meta

Widgets wp_options

Prepared By : Harshad Fefar ( Harivandana College, Rajkot ) 42


SUCSD-RAJKOT MCA-3

Options wp_options

Users wp_users

wp_posts (if added to posts)


hardcoded content wp_options (if added to widgets)
Theme and plugin files (if hardcoded)

wp_posts (if added to posts)


third party content wp_options (if added via widgets or plugins)
Theme and plugin files (if hardcoded)

- You may have noticed that not all of the database tables are included in that table.

- That's because some of them are used to store metadata and others are used to store
relationships both of which will be covered in more detail later in this series.

Prepared By : Mr.Ronak J. Goda


43
SUCSD-RAJKOT MCA-3

Themes And Widgets

What is theme?

- A WordPress theme changes the design of your website, often including its layout.

- Changing your theme changes how your site looks on the front-end, i.e. what a visitor sees
when they browse to your site on the web.

- There are thousands of free WordPress themes in the WordPress.org Theme Directory,
though many WordPress sites use custom themes.

- How to Install a Theme in WordPress

- First you need to download the theme‟s zip file to your computer.

- After that login to your WordPress admin area and go to Appearance » Themes page

- you need to click on Upload theme link at the top.

- You will now see the theme upload box.

- Click on choose file button to select the theme zip file you downloaded to your computer
earlier and then click on the Install now button.

- If you do not want to use a theme right away, then you can click on the live preview button
to test out the theme without activating it.

- Please note that you will have to activate a theme in order to use it on your website.

Prepared By : Mr.Ronak J. Goda 44


SUCSD-RAJKOT MCA-3

Introduction of common WordPress theme template files.

Below is a list of some basic theme templates and files recognized by WordPress.

index.php
- The main template file. It is required in all themes.

style.css
- The main style sheet. It is required in all themes and contains the information header for
your theme.

rtl.css
- The right-to-left stylesheet is included automatically if the website language‟s text
direction is right-to-left.

comments.php
- The comments template.

front-page.php
- The front page template is loaded if a static front page is specified under Admin >
Settings > Reading.

home.php
- The home page template is the front page by default. If you do not set WordPress to use
a static front page, this template is used to show latest posts.

header.php
- The header template file usually contains your site‟s document type, meta information,
links to stylesheets and scripts, and other data.

single.php
- The single post template is used when a visitor requests a single post. For this, and all
other query templates, index.php is used if the query template is not present.

Prepared By : Mr.Ronak J. Goda 45


SUCSD-RAJKOT MCA-3

single-{post-type}.php
- The single post template used when a visitor requests a single post from a custom post
type. For example, single-book.php would be used for displaying single posts from a
custom post type named book. The index.php is used if a specific query template for the
custom post type is not present.

archive-{post-type}.php
- The archive post type template is used when visitors request a custom post type archive.
For example, archive-books.php would be used for displaying an archive of posts from
the custom post type named books. The archive.php template file is used if the archive-
{post-type}.php is not present.

page.php
- The page template is used when visitors request individual pages, which are a built-in
template.

page-{slug}.php
- The page slug template is used when visitors request a specific page, for example one
with the “about” slug (page-about.php).

category.php
- The category template is used when visitors request posts by category.

tag.php
- The tag template is used when visitors request posts by tag.

taxonomy.php
- The taxonomy term template is used when a visitor requests a term in a custom
taxonomy.

author.php
- The author page template is used whenever a visitor loads an author page.

Prepared By : Mr.Ronak J. Goda 46


SUCSD-RAJKOT MCA-3

date.php
- The date/time template is used when posts are requested by date or time. For example,
the pages generated with these slugs:
 http://example.com/blog/2014/
 http://example.com/blog/2014/05/
 http://example.com/blog/2014/05/26/

archive.php
- The archive template is used when visitors request posts by category, author, or date.
Note: this template will be overridden if more specific templates are present like
category.php, author.php, and date.php.

search.php
- The search results template is used to display a visitor‟s search results.

attachment.php
- The attachment template is used when viewing a single attachment like an image, pdf, or
other media file.

image.php
- The image attachment template is a more specific version of attachment.php and is used
when viewing a single image attachment. If not present, WordPress will use
attachment.php instead.

404.php
- The 404 template is used when WordPress cannot find a post, page, or other content
that matches the visitor‟s request.

Using template files


- Within WordPress templates, you can use Template Tags to display information
dynamically, include other template files, or otherwise customize your site.

Prepared By : Mr.Ronak J. Goda 47


SUCSD-RAJKOT MCA-3

For example, in your index.php you can include other files in your final generated page:
- To include the header, use get_header()
- To include the sidebar, use get_sidebar()
- To include the footer, use get_footer()
- To include the search form, use get_search_form()
- To include custom theme files, use get_template_part()

Here is an example of WordPress template tags to include specific templates into your page:
- <?php get_sidebar(); ?>
- <?php get_template_part( 'featured-content' ); ?>
- <?php get_footer(); ?>

What is widget & widget Areas?

- A WordPress Widget is a small block that performs a specific function.

- You can add these widgets in sidebars also known as widget-ready areas on your web
page.

- WordPress widgets were originally created to provide a simple and easy-to-use way of
giving design and structure control of the WordPress theme to the user.

Create Widget Area

The following should be added to your Theme's functions.php file:


<?php
/* Register our sidebars and widgetized areas. */
function arphabet_widgets_init() {
register_sidebar( array(
'name' => 'Home right sidebar',
'id' => 'home_right_1',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2 class="rounded">',
'after_title' => '</h2>',
) );
}

Prepared By : Mr.Ronak J. Goda 48


SUCSD-RAJKOT MCA-3

add_action( 'widgets_init', 'arphabet_widgets_init' );


?>

How to display new Widget Areas


You can display your new widget area by:
1. Adding the code directly to a theme file like the sidebar.php file; or
2. Using a custom function with hook in your functions.php file.
Here's some example code that is a common way to add your new widget area to a parent or
child theme:
<?php if ( is_active_sidebar( 'home_right_1' ) ) : ?>
<div id="primary-sidebar" class="primary-sidebar widget-area" role="complementary">
<?php dynamic_sidebar( 'home_right_1' ); ?>
</div><!-- #primary-sidebar -->
<?php endif; ?>

Widget Management

Archive Widget
- The Archive widget is used to organize your previously published posts by month.

- Bloggers use the archives widget in their sidebar so they and their readers can easily
access previous months or years posts.

- For example, clicking on a May 2011 archive link displays all your posts written in that
month.

Calendar
- The calendar widget creates a calendar in your sidebar with clickable links to your blogs
posts for particular dates.
- Dates that appear in bold type indicate dates you‟ve posted.

Prepared By : Mr.Ronak J. Goda 49


SUCSD-RAJKOT MCA-3

Categories Widget
- The Categories widget displays a list of the categories that you‟ve assigned to posts.

- It helps your readers quickly see what topics you write about.

- If you want to display your categories in a specific order, you can build a custom menu
then add your categories to your sidebar using the Custom menu widget instead.

Custom menu
- The Custom menu widget allows you to display pages, categories, and custom links with
a single widget.

- To use you first need to set up your custom menu in Appearance > Menu.

Meta
The Meta widget is a simple widget for:
- Your blog dashboard (click on Site Admin when you are logged into your account) Log
in/out
- Entries RSS (your post RSS feed URL)
- Comments RSS (your comment RSS feed URL)

Pages
- The Pages widget displays a list of your pages in the sidebar.

- It is commonly used for themes that don‟t have page links in the top navigation.

- The alternative is to use a custom navigation menu to set up your top navigation.

- You can customise the Page widget to list pages by:


o Page title – this displays the pages in alphabetical order
o Page order – use this option to display pages your preferred order
o Page ID – this displays the pages in the pages were first created in your Dashboard

Prepared By : Mr.Ronak J. Goda 50


SUCSD-RAJKOT MCA-3

The Exclude option is used to if you want to keep certain pages from being listed in the widget.
You exclude pages as follows:
- Locate the Page ID you want to exclude by going to Pages > Edit

- Hover over the title of the page you want to exclude.

- The status bar of your browser will display a URL with a numeric ID. This is the page ID.

- Enter the Page IDs; separated by commas if more than one Page ID and click Save.

Recent Comments
- The Recent Comments Widget displays the most recent comments left on your blog by
readers.

- Educators use this widget because seeing recently approved comments in the sidebar
can be very motivating for students.

Recent Posts
- The Recent Posts widget displays the most recent posts you have published.

- It makes it easier for readers to see what‟s new on your blog.

RSS
- The RSS Just Better widget allows you to add a customized list of RSS feeds to your
sidebar.

- It is added to Appearance > Widgets when the RSS Just Better plugin is activated in
Plugins.

Search
- The Search Widget adds a search box to your sidebar.

- It makes it easier for readers to search the contents of your blog.

Prepared By : Mr.Ronak J. Goda 51


SUCSD-RAJKOT MCA-3

Tag Cloud
- The Tag Cloud widget displays a list of your top 45 tags that you‟ve assigned to posts.

- The larger the size of the tag, the more often you‟ve assigned the tag to a post

- It helps your readers quickly see what topics you write about the most.

Text Widget
- The text widget can be used for lots of different purposes. It allows you to add simple
text, display links, insert images, embed HTML code.

- You can use as many text widgets in your sidebars, each with different content.

- It‟s one of the most useful widget because you can use it to add content from other
sources to your sidebar using their embed code.

Inactive Sidebar (not used)


- If you want to remove a widget from a Sidebar but save its settings for future use, drag it
into the Inactive Widgets section. If you simply want to delete the Widget from your
Sidebar, click the Delete link within the Widget.

- The small arrow next to the Sidebar title will toggle the sidebar open and closed. If you
drag and drop a widget onto a closed sidebar, the sidebar and widget will automatically
open.

Prepared By : Mr.Ronak J. Goda 52


SUCSD-RAJKOT MCA-3

Inactive Widgets
- What probably happened is that you dropped one of them over the "Available widgets"
space and it dissapeared.
- But don't worry that doesn't mean that the widget is gone, widgets cannot "dissapear",
in the worst case you just lost the data of the widget.

- For example if you have a text widget in your colum, with the title "My cool widget" and
the text "Hey check this out", and you decide to temporarly remove it from your website,
but wish to keep the text data, you would drop it to the "Inactive" space. You can then
drop it back whenever you wish to use it again with the same text. BUT, if you remove it
completely, then there will always still be the "Text" widget available in the upper space
"Available widgets".

Plugin
- A plugin is a piece of software containing a group of functions that can be added to a
WordPress website.

- They can extend functionality or add new features to your WordPress websites.

- WordPress plugins are written in the PHP programming language and integrate
seamlessly with WordPress.

How to install and activate plugin


All WordPress Plugins install in two ways. Automatic and manual.

- To automatically install a WordPress Plugin, you must have the following FTP access
information ready.
o Server Hostname for FTP access
o FTP Username (not the same as your WordPress password)
o FTP Password
o Connection Type (FTP, FTPS (SSL) )
o Go to Plugins > Add New and enter the name or search term to find the
WordPress Plugin you wish to add.

Prepared By : Mr.Ronak J. Goda 53


SUCSD-RAJKOT MCA-3

- To view information about the Plugin, installation help, applicable WordPress versions,
etc., click Details under the Plugin name.

- To install the Plugin, click Install under the Plugin name.

- When WordPress asks, enter the above access information and proceed.

- If the WordPress Plugin installs correctly, the resulting screen will notify you that the
Plugin is installed and awaiting activation.

- If you wish to activate it, click Activate. If you wish to delay, leave the page.

Useful plugins for website

Seo yoast

- It is one of the most downloaded WordPress plugin of all times.

- Yoast‟s WordPress SEO is a comprehensive solution for all your on-site SEO needs.

- It allows you to add SEO title, meta description, and meta keywords to each post and page
of your site.

- You can also write custom title for your main site, archives, category and tag pages.

- It also adds Open Graph meta data, Twitter Cards, Sitemaps and ping search engines
whenever you update your site.

Contact form 7
- Contact Form 7 can manage multiple contact forms, plus you can customize the form and
the mail contents flexibly with simple markup.

- The form supports Ajax-powered submitting, CAPTCHA, Akismet spam filtering and so on.

- Contact Form 7 4.7 is now available.

Prepared By : Mr.Ronak J. Goda 54


SUCSD-RAJKOT MCA-3

Woocommerce

- WooCommerce is a free eCommerce plugin that allows you to sell anything, beautifully.
Built to integrate seamlessly with WordPress, WooCommerce is the world's favorite
eCommerce solution that gives both store owners and developers complete control.

- WooCommerce is an open source e-commerce plugin for WordPress. It is designed for


small to large-sized online merchants using WordPress.

- Launched on September 27, 2011, the plugin quickly became popular for its simplicity to
install and customize and free base product.

WP Super Cache

- This plugin generates static html files from your dynamic WordPress blog.

- After a html file is generated your webserver will serve that file instead of processing the
comparatively heavier and more expensive WordPress PHP scripts.

- This plugin will help your server cope with a front page appearance on digg.com or other
social networking site.

- If for some reason "supercaching" doesn't work on your server then don't worry.

- Caching will still be performed, but every request will require loading the PHP engine.

- Super Cached html files will be served more quickly than PHP generated cached files but
in every day use, the difference isn't noticeable.

Regenerate Thumbnails
- Regenerate Thumbnails allows you to regenerate the thumbnails for all of your image
attachments.

- This is very handy if you‟ve changed any of your thumbnail dimensions (via Settings →
Media) or switched to a new theme with different featured image sizes after previously
uploading images.

Prepared By : Mr.Ronak J. Goda 55


SUCSD-RAJKOT MCA-3

Advanced Custom Fields

- ACF features an easy to use and powerful library of functions to load and display custom
field data.

- It is based off and uses the native WP postmeta functions, but also formats the value
based on the field‟s type and field‟s settings.

- This allows you to write less code and produce smarter websites!

- ACF requires you to have some prior knowledge of modifying your theme and
understanding PHP code.

- Once you are editing the correct template file, a simple the_field('hero_text') will echo
(display) the value, and get_field('hero_text') will return it for use as a variable.

- Be sure to read over all the available functions before starting work on the theme to
ensure you only have to write the code once!

Prepared By : Mr.Ronak J. Goda 56


SUCSD-RAJKOT MCA-3

Theme Development

Anatomy of a Theme: header.php, footer.php and sidebar.php

Header.php
- Use the proper DOCTYPE.

- The opening <html> tag should include language_attributes().

- The <meta> charset element should be placed before everything else, including the
<title> element.

- Use bloginfo() to set the <meta> charset and description elements.

- Use wp_title() to set the <title> element. See why.

- Use Automatic Feed Links to add feed links.

- Add a call to wp_head() before the closing </head> tag. Plugins use this action hook to
add their own scripts, stylesheets, and other functionality.

- Do not link the theme stylesheets in the Header template. Use the wp_enqueue_scripts
action hook in a theme function instead.
- Here's an example of a correctly-formatted HTML5 compliant head area:
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<title><?php wp_title(); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php if ( is_singular() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' ); ?>
<?php wp_head(); ?>
</head>

Prepared By : Mr.Ronak J. Goda 57


SUCSD-RAJKOT MCA-3

Footer.php
- Use the wp_footer() call, to appear just before closing body tag.

<?php wp_footer(); ?>


</body>
</html>

sidebar.php

- The Theme should be widgetized as fully as possible.

- Any area in the layout that works like a widget (tag cloud, blogroll, list of categories) or
could accept widgets (sidebar) should allow widgets.

- Content that appears in widgetized areas by default (hard-coded into the sidebar, for
example) should disappear when widgets are enabled from Appearance > Widgets.

Template Files (style.css, index.php, page.php, home.php, archive.php, single.php,


comments.php, search.php, attachment.php, 404.php, category.php, tag.php, author.php,
date.php)

style.css
- In addition to CSS style information for your theme, style.css provides details about the
Theme in the form of comments.

- The stylesheet must provide details about the Theme in the form of comments.

- No two Themes are allowed to have the same details listed in their comment headers, as
this will lead to problems in the Theme selection dialog.

- If you make your own Theme by copying an existing one, make sure you change this
information first.

- The following is an example of the first few lines of the stylesheet, called the stylesheet
header, for the Theme "Twenty Thirteen":

Prepared By : Mr.Ronak J. Goda 58


SUCSD-RAJKOT MCA-3

/*
Theme Name: Twenty Thirteen
Theme URI: http://wordpress.org/themes/twentythirteen
Author: the WordPress team
Author URI: http://wordpress.org/
Description: The 2013 theme for WordPress takes us back to the blog, featuring a full range of
post formats, each displayed beautifully in their own unique way. Design details abound,
starting with a vibrant color scheme and matching header images, beautiful typography and
icons, and a flexible layout that looks great on any device, big or small.
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: black, brown, orange, tan, white, yellow, light, one-column, two-columns, right-sidebar,
flexible-width, custom-header, custom-menu, editor-style, featured-images, microformats,
post-formats, rtl-language-support, sticky-post, translation-ready
Text Domain: twentythirteen

This theme, like WordPress, is licensed under the GPL.


Use it to make something cool, have fun, and share what you've learned with others.
*/
- The comment header lines in style.css are required for WordPress to be able to identify
the Theme and display it in the Administration Panel under Design > Themes as an
available Theme option along with any other installed Themes.

index.php
- Display a list of posts in excerpt or full-length form. Choose one or the other as
appropriate.

- Include wp_link_pages() to support navigation links within posts.

page.php
- Display page title and page content.
- Display comment list and comment form (unless comments are off).
- Include wp_link_pages() to support navigation links within a page.
- Metadata such as tags, categories, date and author should not be displayed.
- Display an "Edit" link for logged-in users with edit permissions.

Prepared By : Mr.Ronak J. Goda 59


SUCSD-RAJKOT MCA-3

home.php

- The home page template, which is the front page by default. If you use a static front page
this is the template for the page with the latest posts.

archive.php

- Display archive title (tag, category, date-based, or author archives).


- Display a list of posts in excerpt or full-length form. Choose one or the other as
appropriate.
- Include wp_link_pages() to support navigation links within posts.

single.php
- Include wp_link_pages() to support navigation links within a post.

- Display post title and post content.

o The title should be plain text instead of a link pointing to itself.

- Display the post date.

o Respect the date and time format settings unless it's important to the design.
(User settings for date and time format are in Administration Panels > Settings >
General).

o For output based on the user setting, use the_time( get_option( 'date_format' ) ).

- Display the author name (if appropriate).

- Display post categories and post tags.

- Display an "Edit" link for logged-in users with edit permissions.

- Display comment list and comment form.

- Show navigation links to next and previous post using previous_post_link() and
next_post_link().

Prepared By : Mr.Ronak J. Goda 60


SUCSD-RAJKOT MCA-3

comments.php
- Author comment should be highlighted differently.

- Display gravatars (user avatars) if appropriate.

- Support threaded comments.

- Display trackbacks/pingbacks.

- This file shouldn‟t contain function definitions unless in the function_exist() check to
avoid redeclaration errors. Ideally all functions should be in functions.php.

search.php
- Display a list of posts in excerpt or full-length form.

- Choose one or the other as appropriate.

- The search results page shows the search term which generated the results.

- It's a simple but useful way to remind someone what they just searched for -- especially
in the case of zero results.

- Use the_search_query() or get_search_query() (display or return the value,


respectively). For example:

< h2><?php printf( ( 'Search Results for: %s' ), '<span>' . get_search_query() .


'</span>'); ?></h2>

- It's a good practice to include the search form again on the results page. Include it with:
get_search_form().

attachment.php
- Attachment template. Used when viewing a single attachment.

Prepared By : Mr.Ronak J. Goda 61


SUCSD-RAJKOT MCA-3

404.php

- The 404 Not Found template.

- Used when WordPress cannot find a post or page that matches the query.

- These files have a special meaning with regard to WordPress because they are used as a
replacement for index.php, when available, according to the Template Hierarchy, and
when the corresponding Conditional Tag returns true.

- For example, if only a single post is being displayed, the is_single() function returns 'true',
and, if there is a single.php file in the active Theme, that template is used to generate the
page.

category.php
- Returns the description of a category defined in the category settings screen for the
current category (Posts > Categories).

- If used in the archive.php template, place this function within the is_category()
conditional statement. Otherwise, this function will stop the processing of the page for
monthly and other archive pages.

<?php echo category_description( $category_id ); ?>

tag.php
- When a viewer clicks on a link to one of the Tags on your site, he or she is taken to a page
listing the Posts using that particular Tag in chronological order, from newest Posts at the
top to oldest at the bottom.

- There are many display choices, including whether to display the complete post or post
excerpts, and what additional information to display (title, author, publish date, last
modified time, etc.). Each theme makes different choices, and you might want to change
them.

Prepared By : Mr.Ronak J. Goda 62


SUCSD-RAJKOT MCA-3

author.php

- When a viewer clicks on a link to a post author, by default he or she is taken to a page
listing the posts from that particular author in chronological order, from newest posts at
the top to oldest at the bottom.
- There are many display choices, including whether to display the complete post or post
excerpts, and what additional information to display (title, category, publish date, last
modified time, etc.). Each theme makes different choices, and you might want to change
them.

The Loop (have_posts (), the_post())

- This function checks to see if the current WordPress query has any results to loop over.
This is a boolean function, meaning it returns either TRUE or FALSE.

- As a side effect, have_posts starts, steps through, or resets The Loop. At the end of the
loop, have_posts returns 0 after calling rewind_posts.

The following example can be used to determine if any posts exist, and if they do, loop through
them.
< ?php
if ( have_posts() ) :
while ( have_posts() ) : the_post();
// Your loop code
endwhile;
else :
echo wpautop( 'Sorry, no posts were found' );
endif;
?>

Prepared By : Mr.Ronak J. Goda 63


SUCSD-RAJKOT MCA-3

Template Tags
- A template tag is a PHP function used to generate and display information dynamically.

- WordPress Themes contain different templates and theme developers use template tags
to fetch and display dynamic data.

- WordPress has many built-in template tags that can be used in WordPress themes.

- WordPress plugins and themes can also define their own template tags and use them in
different templates.

<?php the_author(); ?>

The author template tag displays the name of the post author in WordPress.

1. General tags

wp_head()
- The wp_head action hook is triggered within the <head></head> section of the user's
template by the wp_head() function.

- Although this is theme-dependent, it is one of the most essential theme hooks, so it is


widely supported.

- This function is simply a wrapper for:


<?php
do_action('wp_head');
?>

get_footer()
- Includes the footer.php template file from your current theme's directory. if a name is
specified then a specialised footer footer-{name}.php will be included.
- If the theme contains no footer.php file then the footer from the default theme wp-
includes/theme-compat/footer.php will be included.
<?php get_footer( $name ); ?>

Prepared By : Mr.Ronak J. Goda 64


SUCSD-RAJKOT MCA-3

get_header()
- Includes the header.php template file from your current theme's directory.

- If a name is specified then a specialised header header-{name}.php will be included

- If the theme contains no header.php file then the header from the default theme wp-
includes/theme-compat/header.php will be included.
<?php get_header( $name ); ?>

get_sidebar()
- Includes the sidebar template for a theme or if a name is specified then a specialised
sidebar will be included.

- For the parameter, if the file is called “sidebar-special.php” then specify “special”.
<?php get_sidebar('nice-bar'); ?>

get_search_form()
- Will first attempt to locate the searchform.php file in either the child or the parent, then
load it.

- If it doesn‟t exist, then the default search form will be displayed.

- The default search form is HTML, which will be displayed.

- There is a filter applied to the search form HTML in order to edit or replace it.

- The filter is „get_search_form‟.

- This function is primarily used by themes which want to hardcode the search form into
the sidebar and also by the search widget in WordPress.

- There is also an action that is called whenever the function is run called,
„pre_get_search_form‟.

- This can be useful for outputting JavaScript that the search relies on or various
formatting that applies to the beginning of the search.

Prepared By : Mr.Ronak J. Goda 65


SUCSD-RAJKOT MCA-3

- To give a few examples of what it can be used for.


<?php get_search_form( $echo ); ?>

bloginfo()

- Displays information about the current site.

function bloginfo( $show = '' ) {


echo get_bloginfo( $show, 'display' );
}

Wp_title()
- Using wp_title() through you can get title of page.
<?php wp_title(); ?>

single_post_title()
- This is optimized for single.php template file for displaying the post title.
- It does not support placing the separator after the title, but by leaving the prefix
parameter empty, you can set the title separator manually.
- The prefix does not automatically place a space between the prefix, so if there should be
a space, the parameter value will need to have it at the end.
<?php single_post_title(); ?>

get_footer()
- Includes the footer.php template file from your current theme's directory. if a name is
specified then a specialised footer footer-{name}.php will be included.
- If the theme contains no footer.php file then the footer from the default theme wp-
includes/theme-compat/footer.php will be included.
<?php get_footer( $name ); ?>

comments_template()
- The comments_template filter hook filters the path to the theme template file used for
the comments template. It is part of the comments_template() function.
- The comments_template filter can be used to load a custom template form a plugin
which replaces the theme's default comment template.
- < ?php add_filter( "comments_template", "my_plugin_comment_template" ); ?>

Prepared By : Mr.Ronak J. Goda 66


SUCSD-RAJKOT MCA-3

add_theme_support()
- Themes need to use add_theme_support() in the functions.php file to tell WordPress
which post formats to support by passing an array of formats like so:
<?php add_theme_support( 'post-formats', array( 'aside', 'gallery' ) ); ?>

Formats in a Child Theme


- Child Themes inherit the post formats defined by the parent theme.

- Calling add_theme_support() for post formats in a child theme must be done at a later
priority than that of the parent theme and will override the existing list, not add to it.

add_action („after_setup_theme', 'childtheme_formats', 11 );


function childtheme_formats(){
add_theme_support („post-formats', array („aside‟, 'gallery', „link‟));
}

- Calling remove_theme_support('post-formats') will remove it all together.

- If your plugin

- or theme needs to be compatible with earlier versions of WordPress, you need to add
terms named post-format-$format to the "post_format" taxonomy. For example,

- wp_insert_term( 'post-format-aside', 'post_format' );

- You must also register the post_format taxonomy with register_taxonomy().

get_template_directory_uri()

- Retrieves the absolute path to the directory of the current theme.


- Returns an absolute server path (eg: /home/user/public_html/wp-
content/themes/my_theme), not a URI.
- In the case a child theme is being used, the absolute path to the parent theme directory
will be returned. Use get_stylesheet_directory() to get the absolute path to the child
theme directory.
- To retrieve the URI of the stylesheet directory use get_stylesheet_directory_uri() instead.

Prepared By : Mr.Ronak J. Goda 67


SUCSD-RAJKOT MCA-3

- <?php echo get_template_directory(); ?>


- < ?php include( get_template_directory() . '/includes/myfile.php'); ? >

body_class()

- The "body_class" filter is used to filter the classes that are assigned to the body HTML
element on the current page.

- A plugin (or theme) can filter these classes with the code:

- <?php add_filter( 'body_class', 'filter_function_name' ) ?>

- Where 'filter_function_name' is the function WordPress should call when the classes are
being assigned.

- Note that the filter function must return the array of classes after it is finished
processing, or all of the classes will be cleared and could seriously impact the visual state
of a user's site.

- filter_function_name should be unique function name. It cannot match any other


function name already declared.

- This filter is used by the get_body_class() function.

2. Author tags

the_author()
- The author of a post can be displayed by using this Template Tag. This tag must be used
within The Loop.

- To return to PHP rather than displaying, use get_the_author().

- <?php the_author(); ?>

get_the_author()
Prepared By : Mr.Ronak J. Goda 68
SUCSD-RAJKOT MCA-3

- Retrieve the post author's display name. This tag must be used within The Loop.

- To get the post author's ID, use get_the_author_meta( 'ID' ).

- To display a page for authors which have no posts, see this discussion.

- Since WordPress 2.1 parameters are deprecated (not the function).


<?php $author = get_the_author(); ?>

the_author_link()
- This tag displays a link to the Website for the author of a post.

- The Website field is set in the user's profile (Administration > Profile > Your Profile).

- The text for the link is the author's Profile Display name publicly as field. This tag must be
used within The Loop.

get_the_author_link()
- This tag returns a link to the Website for the author of a post.

- The Website field is set in the user's profile (Administration > Users > Your Profile).

- The text for the link is the author's Profile Display name publicly as field.

- This tag must be used within The Loop.

- get_the_author_link() returns the link for use in PHP.

- To display the link instead, use the_author_link().


< ?php get_the_author_link(); ? >

the_author_meta()
- The the_author_meta Template Tag displays a desired meta data field for a user.

- Only one field is returned at a time, you need to specify which you want.

Prepared By : Mr.Ronak J. Goda 69


SUCSD-RAJKOT MCA-3

- If this tag is used within The Loop, the user ID value need not be specified, and the
displayed data is that of the current post author.

- A user ID can be specified if this tag is used outside The Loop.

- If the meta field does not exist, nothing is printed.

- NOTE: Use get_the_author_meta() if you need to return (and do something with) the
field, rather than just display it.
< ?php the_author_meta( $field, $userID ); ? >

the_author_posts()

- Displays the total number of posts an author has published.

- Drafts and private posts aren't counted.

- This tag must be used within The Loop.


< ?php the_author_posts(); ?>
< p><?php the_author(); ?> has blogged <?php the_author_posts(); ?>
posts</p>

3. Category tags

category_description()
- Returns the description of a category defined in the category settings screen for the
current category (Posts > Categories).

- If used in the archive.php template, place this function within the is_category()
conditional statement.

- Otherwise, this function will stop the processing of the page for monthly and other
archive pages.

< ?php echo category_description( $category_id ); ? >

Prepared By : Mr.Ronak J. Goda 70


SUCSD-RAJKOT MCA-3

single_cat_title()
- Useful for category template files for displaying the category page title.

- The prefix does not automatically place a space between the prefix, so if there should be
a space, the parameter value will need to have it at the end.

the_category()
- Displays a link to the category or categories a post belongs to. This tag must be used
within The Loop.
- <?php the_category( $separator, $parents, $post_id ); ?>

4. Link tags

category_description()
- Returns the description of a category defined in the category settings screen for the
current category (Posts > Categories).

- If used in the archive.php template, place this function within the is_category()
conditional statement.

- Otherwise, this function will stop the processing of the page for monthly and other
archive pages.
< ?php echo category_description( $category_id ); ?>

single_cat_title()
- Useful for category template files for displaying the category page title.

- The prefix does not automatically place a space between the prefix, so if there should be
a space, the parameter value will need to have it at the end.
<?php single_cat_title('Category: '); ?>

the_category()
- Displays a link to the category or categories a post belongs to. This tag must be used
within The Loop.
< ?php the_category( $separator, $parents, $post_id ); ? >

Prepared By : Mr.Ronak J. Goda 71


SUCSD-RAJKOT MCA-3

Link tags

the_permalink()
- Displays the URL for the permalink to the post currently being processed in The Loop.

- This tag must be within The Loop, and is generally used to display the permalink for each
post, when the posts are being displayed.

- Since this template tag is limited to displaying the permalink for the post that is being
processed, you cannot use it to display the permalink to an arbitrary post on your
weblog.

- Refer to get_permalink() if you want to get the permalink for a post, given its unique post
id.
< ?php the_permalink(); ? >

get_permalink()
- This function is gives you a link of post.
<?php get_permalink(); ?>

home_url()
- The home_url template tag retrieves the home URL for the current site, optionally with
the $path argument appended.
- The function determines the appropriate protocol, "https" if is_ssl() and "http"
otherwise.
- If the $scheme argument is "http" or "https" the is_ssl() check is overridden.
- In case of WordPress Network Setup, use network_home_url() instead.
<?php home_url( $path, $scheme ); ?>

get_home_url()
- Returns the „home‟ option with the appropriate protocol.
- The protocol will be „https‟ if is_ssl() evaluates to true; otherwise, it will be the same as
the „home‟ option.
- If $scheme is „http‟ or „https‟, is_ssl() is overridden.
<?php echo get_home_url(); ?>

Prepared By : Mr.Ronak J. Goda 72


SUCSD-RAJKOT MCA-3

site_url()
- The site_url template tag retrieves the site url for the current site (where the WordPress
core files reside) with the appropriate protocol, 'https' if is_ssl() and 'http' otherwise.

- If scheme is 'http' or 'https', is_ssl() is overridden. Use this to get the "WordPress
address" as defined in general settings.

- Use home_url() to get the "site address" as defined in general settings.

- In case of WordPress Network setup, use network_site_url() instead.


<?php echo site_url(); ?>

get_site_url()
- Returns the „site_url‟ option with the appropriate protocol, „https‟ if is_ssl() and „http‟
otherwise.
- If $scheme is „http‟ or „https‟, is_ssl() is overridden.
<?php echo get_site_url(); ?>

Post tags

the_content()
- Retrieve the post content. (Must be used in a Loop).

- An important difference from the_content() is that get_the_content() does not pass the
content through the 'the_content' filter.

- This means that get_the_content() will not auto-embed videos or expand shortcodes,
among other things.
<?php get_the_content( $more_link_text, $stripteaser ) ?>

the_excerpt()
- This is either a user-supplied excerpt, that is returned unchanged, or an automatically
generated word-counted trimmed-down version of the full post content.

Prepared By : Mr.Ronak J. Goda 73


SUCSD-RAJKOT MCA-3

- The auto-generated excerpts have all shortcodes and tags removed which means it is just
an unformatted string that would not see any line-breaks in any form of output, since the
actual line-breaks in the raw text are also removed.

- When called through the_excerpt() this implies that the auto-gen excerpts are just raw
text with <p></p> tags wrapped around it, basically.

- Auto-gen excerpts have a "more" tag appended to them. This tag is '[…]' by default. It can
be changed through the excerpt_more filter.

- The default word length is 55 words. It can be changed through the excerpt_length filter.

<?php the_excerpt( $post ) ?>

the_ID()
- Displays the numeric ID of the current post. This tag must be within The Loop.

- Note: This function displays the ID of the post, to return the ID use get_the_ID().
<?php the_ID(); ?>

the_tags()
- This template tag displays a link to the tag or tags a post belongs to.
- If no tags are associated with the current entry, nothing is displayed.
- This tag should be used within The Loop.
<?php the_tags( $before, $sep, $after ); ?>

the_title()
- Displays or returns the title of the current post.

- This tag may only be used within The Loop, to get the title of a post outside of the loop
use get_the_title.

- If the post is protected or private, this will be noted by the words "Protected: " or
"Private: " prepended to the title.
<?php the_title( $before, $after, $echo ); ?>

Prepared By : Mr.Ronak J. Goda 74


SUCSD-RAJKOT MCA-3

get_the_title()
- If the post is protected and the visitor is not an admin, then “Protected” will be displayed
before the post title.

- If the post is private, then “Private” will be located before the post title.
<?php the_title(); ?>

the_date()
- Will only output the date if the current post‟s date is different from the previous one
output.

- i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
function is called several times for each post.

- HTML output can be filtered with „the_date‟. Date string output can be filtered with
„get_the_date‟.
<?php the_date(); ?>

get_the_date()
- The get_the_date template tag retrieves the date the current $post was written.

- Unlike the_date() this tag will always return the date.

- Modify output with 'get_the_date' filter.


<?php $pfx_date = get_the_date( $format, $post_id ); ?>

the_time()
- Displays the time of the current post.

- To return the time of a post, use get_the_time().

- This tag must be used within The Loop.


- <?php the_time( $d ); ?>

Prepared By : Mr.Ronak J. Goda 75


SUCSD-RAJKOT MCA-3

next_post_link()
- Used on single post permalink pages, this template tag displays a link to the next post
which exists in chronological order from the current post.

- In standard usage (within the default, unaltered loop) next_post_link will generate a link
to a post that is newer (more recent) than the current post.

- This is in contrary to the similarly-named previous_posts_link, which will typically link to


a page of posts that is older than the current batch.

- This tag must be used in The Loop.


<?php next_post_link( $format, $link, $in_same_term = false, $excluded_terms = '',
$taxonomy = 'category' ); ?>

- previous_post_link()
Prints a link to the previous set of posts within the current query.

- If you need the values for use in PHP, use get_previous_posts_link().

- Because post queries are usually sorted in reverse chronological order, next_posts_link()
usually points to older entries (toward the end of the set) and previous_posts_link()
usually points to newer entries (toward the beginning of the set).
< ?php previous_posts_link( $label ); ?>

posts_nav_link()
- Displays links for next and previous pages. Useful for providing "paged" navigation of
index, category and archive pages.

- For displaying next and previous pages of posts see next_posts_link() and
previous_posts_link().

- For displaying next and previous post navigation on individual posts, see next_post_link()
and previous_post_link().
<?php posts_nav_link( $sep, $prelabel, $nextlabel ); ?>

Prepared By : Mr.Ronak J. Goda 76


SUCSD-RAJKOT MCA-3

post_class()

- WordPress theme authors who want to have finer css control options for their post
styling, have the post_class function available.

- When the post_class function is added to a tag within the loop, for example <div <?php
post_class(); ?> >, it will print out and add various post-related classes to the div tag.

- It can also be used outside the loop with the optional post_id parameter.

- This function is typically used in the index.php, single.php, and other template files that
feature hierarchical post listings.

- If you would prefer to have the post classes returned instead of echoed, you would want
to use get_post_class().

- Note: get_post_class() does not return a string, but an array that must be processed to
produce text similar to what is echoed by post_class().

- For css classes intended to help target entire pages, see body_class(), and for classes
targeting comment listings, see comment_class().
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?> >

6. Post Thumbnail tags

has_post_thumbnail()
- Gets the direct image URL for the featured image of the current post, or the given Post
ID.
- This tag must be used within The Loop.
- Use has_post_thumbnail() to check whether a Feature Image has been added to the
post.
- To enable post thumbnails, the current theme must include add_theme_support( 'post-
thumbnails' ); in its functions.php file. See also Post Thumbnails.
- <?php the_post_thumbnail_url( $size ); ?>

Prepared By : Mr.Ronak J. Goda 77


SUCSD-RAJKOT MCA-3

get_post_thumbnail_id()
- If a featured image (formerly known as post thumbnail) is set - Returns the ID of the
featured image attached to the post

- If no such attachment exists, the function returns an empty string

- If the post does not exist, the function returns false

- Note: To enable featured images, see post thumbnails, the current theme must include
add_theme_support( 'post-thumbnails' ); in its functions.php file.
<?php $post_thumbnail_id = get_post_thumbnail_id( $post_id ); ?>

the_post_thumbnail()
- When a theme adds „post-thumbnail‟ support, a special „post-thumbnail‟ image size is
registered, which differs from the „thumbnail‟ image size managed via the Settings >
Media screen.

- When using the_post_thumbnail() or related functions, the „post-thumbnail‟ image size is


used by default, though a different size can be specified instead as needed.
<?php echo the_post_thumbnail(); ?>

get_the_post_thumbnail()
- When a theme adds „post-thumbnail‟ support, a special „post-thumbnail‟ image size is
registered, which differs from the „thumbnail‟ image size managed via the Settings >
Media screen.

- When using the_post_thumbnail() or related functions, the „post-thumbnail‟ image size is


used by default, though a different size can be specified instead as needed.
<?php echo get_the_post_thumbnail( $post_id, $size, $attr ); ?>

Prepared By : Mr.Ronak J. Goda 78


SUCSD-RAJKOT MCA-3

7. Navigation Menu tag

wp_nav_menu()
- The wp_nav_menu function displays menus within WordPress sites, and in this video
we look at how to use it to create our primary menu.
- In addition to looking at the menu function, we show how to enable custom menus
for a theme as well as register menu locations for your site.
< ?php wp_nav_menu( array( 'theme_location' => 'header-menu' ) ); ?>

8. Conditional Tags
is_archive()

- This Conditional Tag checks if any type of Archive page is being displayed.
- An Archive is a Category, Tag, Author, Date, Custom Post Type or Custom Taxonomy based
pages.
- This is a boolean function, meaning it returns either TRUE or FALSE.
<?php is_archive(); ?>

is_category()
- If the $category parameter is specified, this function will additionally check if the query is for
one of the categories specified.
<?php is_category(); ?>

is_front_page()
- This Conditional Tag checks if the main page is a posts or a Page.
- This is a boolean function, meaning it returns either TRUE or FALSE.
- It returns TRUE when the main blog page is being displayed and the Settings -> Reading ->
Front page displays is set to "Your latest posts", or when is set to "A static page" and the
"Front Page" value is the current Page being displayed.
<?php is_front_page(); ?>

Prepared By : Mr.Ronak J. Goda 79


SUCSD-RAJKOT MCA-3

is_home()
- The blog homepage is the page that shows the time-based blog content of the site.

- is_home() is dependent on the site‟s “Front page displays” Reading Settings


„show_on_front‟ and „page_for_posts‟.

- If a static page is set for the front page of the site, this function will return true only on
the page you set as the “Posts page”.
<?php is_home(); ?>

is_page()

- If the $page parameter is specified, this function will additionally check if the query is for
one of the pages specified.
<?php if( is_page== “contact.php” ) { echo “This is contact page.”; } ?>

is_single()

- This conditional tag checks if a singular post is being displayed, which is the case when one
of the following returns true: is_single(), is_page() or is_attachment().

- If the $post_types parameter is specified, the function will additionally check if the query is
for one of the post types specified.
<?php is_singular( $post_types ); ?>

is_search()
- This Conditional Tag checks if search result page archive is being displayed.
- This is a boolean function, meaning it returns either TRUE or FALSE.
<?php is_search(); ?>

Prepared By : Mr.Ronak J. Goda 80


M
C
A-
3
SUCSD-RAJKOT MCA-3

is_attachment()
- This Conditional Tag checks if an attachment is being displayed.
- An attachment is an image or other file uploaded through the post editor's upload utility.
- Attachments can be displayed on their own 'page' or template.
- For more information, see Using Image and File Attachments.
- This is a boolean function, meaning it returns either TRUE or FALSE.
<?php is_attachment(); ?>

is_active_sidebar()
- This Conditional Tag checks if a given sidebar is active (in use).
- This is a boolean function, meaning it returns either TRUE or FALSE.
- Any sidebar that contains widgets will return TRUE, whereas any sidebar that does not
contain any widgets will return FALSE.
<?php is_active_sidebar( $index ); ?>

functions.php file
- functions.php or the theme functions file is a template used by WordPress themes.

- It acts like a plugin and gets automatically loaded in both admin and front-end pages of a
WordPress site.

- Usually this file is used to define functions, classes, actions and filters to be used by other
templates in the theme.

- It can be used to add features and extend the functionality of both the theme, and the
WordPress installation.

- The functions.php file can be found in your theme‟s folder.

- You can add both built in WordPress functions and regular PHP functions to hooks and
filters that are predefined throughout the WordPress core.

- Although every theme you have installed on your site has its own functions.php file, only
the active theme‟s file will run its code.

Prepared By : Mr.Ronak J. Goda 81


M
C
A-
3
SUCSD-RAJKOT MCA-3

- If your theme doesn‟t have a functions.php file you can simply create a plain-text file
named functions.php and add it to your theme‟s directory.

- Child themes can have their own functions.php files which can be used to either build on
top of or entirely replace the one in the parent theme directory.

- Some of the things you can do with a functions.php file include use WordPress
actions and filters; you can enable post thumbnails, post formats, and navigation
menus.

Prepared By : Mr.Ronak J. Goda 82


M
C
A-
3

You might also like