Step by step WordPress learning (Part 2)

Step by step WordPress learning

Basic  Idea about wordpress.

WordPress installation (wp-config.php, Network)

WordPress directory structure

Basic idea about Permalinks, Pages, Post, Blog link, comments, User, User role, Theme, Plugins, widget

Theme development

Plugins Development

Widget development

3.  WordPress Directory Structure.

wp-admin

wp-content

blogs.dir

plugins

plugins1

plugins1

themes

theme1

theme2

uploads

wp-includes

index.php

wp-config.php

4. Basic idea about WordPress Permalinks, Pages, Post, link, comments, User, User role, Theme, Plugins, Widget

Permalinks: Permalinks are the permanent URLs to your individual weblog posts, as well as categories and other lists of weblog postings. A permalink is what another weblogger will use to link to your article (or section), or how you might send a link to your story in an e-mail message. The URL to each post should be permanent, and never change — hence permalink.

Permalink Types :

mod_rewrite: “Pretty Permalinks”

Example:

http://example.com/2012/post-name/

or

http://example.com/2012/12/30/post-name

PATHINFO: “Almost Pretty”

Example:

http://example.com/index.php/yyyy/mm/dd/post-name/

Structure Tags:

You can use these tags to customize your “Pretty” or “Almost Pretty” permalinks. A few hints:

•    Make sure to end your structure with either %post_id% or %postname% (e.g. /%year%/%monthnum%/%day%/%postname%/) so that each permalink points to an individual post.

%year%

The year of the post, four digits, for example 2004

%monthnum%

Month of the year, for example 05

%day%

Day of the month, for example 28

%hour%

Hour of the day, for example 15

%minute%

Minute of the hour, for example 43

%second%

Second of the minute, for example 33

%post_id%

The unique ID # of the post, for example 423

%postname%

A sanitized version of the title of the post (post slug field on Edit Post/Page panel). So “This Is A Great Post!” becomes this-is-a-great-post in the URI.

%category%

A sanitized version of the category name (category slug field on New/Edit Category panel). Nested sub-categories appear as nested directories in the URI.

%author%

A sanitized version of the author name.

Page and Post: In WordPress, you can write either posts or pages. When you’re writing a regular blog entry, you write a post. Posts automatically appear in reverse chronological order on your blog’s home page. Pages, on the other hand, are for content such as “About Me,” “Contact Me,” etc. Pages live outside of the normal blog chronology, and are often used to present information about yourself or your site that is somehow timeless — information that is always applicable. You can use Pages to organize and manage any amount of content.

Other examples of common pages include Copyright, Legal Information, Reprint Permissions, Company Information, and Accessibility Statement.

What Pages are Not:

•    Pages are not Posts, nor are they excerpted from larger works of fiction. They do not cycle through your blog’s main page. (Note: You can include Posts in Pages by using the Inline Posts Plugin.

•    Pages cannot be associated with Categories and cannot be assigned Tags. The organizational structure for Pages comes only from their hierarchical interrelationships, and not from Tags or Categories.

•    Pages are not files. They are stored in your database just like Posts are.

•    Pages are “technically” not blogs. Pages are not readily included in your site’s RSS feed. Sophisticated users can adjust any such differences. For most users however, Pages and Posts might attract attention in different ways from humans or search engines. Perhaps the greatest difference between Post and Page, in terms of attracting or impressing an audience, lies in whether your Front page is designated for “your latest posts” or “a static page.” Under Dashboard: Settings: Reading: WordPress allows you to experiment between these configurations. This includes the option of having a static Front page, meanwhile still having a blank static inner page for showing “your latest posts.”

Links:  WordPress allows you to store a set of external links, also known as your blogroll. These links can be put into categories, imported, exported, added, deleted, and edited. The link categories can also be added, deleted, and edited.

Comment: Comments are user feedback. Comment moderation is a feature in WordPress that allows you to prevent comments from appearing on your site without your express approval. Moderation can be very useful in addressing Comment Spam, but it has more general applications as well.

WordPress runs a number of tests on each new comment before posting it to your blog. If a comment fails one of these tests, it is not displayed immediately on the site but is placed in a queue for moderation, the process of manual approval or deletion by the blog’s administrator.

Role: WordPress uses a concept of Roles, designed to give the blog owner the ability to control and assign what users can and cannot do in the blog. A blog owner can manage and allow access to such functions as writing and editing posts, creating Pages, defining links, creating categories, moderating comments, managing plugins, managing themes, and managing other users. The tool that gives the blog owner this control is the ability to assign a Role to a user.

WordPress has five pre-defined Roles: Administrator, Editor, Author, Contributor and Subscriber. Each Role is allowed to perform a set of tasks called Capabilities. There are many Capabilities including publish_posts, moderate_comments, and edit_users. The default Capabilities are pre-assigned to each Role.

Super Admin : Someone with access to the blog network administration features controlling the entire network (See Create a Network).

Administrator : Somebody who has access to all the administration features

Editor : Somebody who can publish and manage posts and pages as well as manage other users’ posts, etc.

Author : Somebody who can publish and manage their own posts.

Contributor : Somebody who can write and manage their posts but not publish them.

Subscriber : Somebody who can only manage their profile.

Theme: Fundamentally, the WordPress Theme system is a way to “skin” your weblog. Yet, it is more than just a “skin.” Skinning your site implies that only the design is changed. WordPress Themes can provide much more control over the look and presentation of the material on your website.

A WordPress Theme is a collection of files that work together to produce a graphical interface with an underlying unifying design for a weblog. These files are called template files. A Theme modifies the way the site is displayed, without modifying the underlying software. Themes may include customized template files, image files (*.jpg, *.gif), style sheets (*.css), custom Pages, as well as any necessary code files (*.php).

Plugins and Widget: WordPress plugins are pieces of code created with the purpose of expanding the functionalities of a software, in this case of WordPress. There are literally thousands of WordPress plugins already created, solving a wide range of problems and needs. WordPress Widgets are WordPress Plugins that add visitor visual and interactivity options and features, such as sidebar widgets for post categories, tag clouds, navigation, search, etc. They were originally designed to provide a simple and easy-to-use way of giving design and structure control of the WordPress Theme to the user in the sidebar, which is now available on properly “widgetized” WordPress Themes to include the header, footer, and elsewhere in the WordPress design and structure.

5.    Theme development

Anatomy of a Theme: WordPress Themes live in subdirectories residing in wp-content/themes/. The Theme’s subdirectory holds all of the Theme’s stylesheet files, template files, and optional functions file (functions.php), JavaScript files, and images. For example, a Theme named “test” would reside in the directory wp-content/themes/test/. Avoid using numbers for the theme name, as this prevents it from being displayed in the available themes list.

Anatomy of a WordPress theme

The cheatsheet for how your blog works

WordPress themes are made up of a folder of template files, each of which controls a specific piece of your theme. Parts of your site that remain static no matter what page you’re on are controlled by header, sidebar and footer files. You can hack these files so they detect what page you are on and serve different content accordingly, such as display different navigation on posts than on pages; however it is most common for these sections to look the same throughout the site.

header.php

Global file that displays headers and navigation. Also contains HTML code.

The Loop

The display of contents of the main area of your site are controlled by individual WordPress theme template files using what’s called “the loop”.

sidebar.php

Sidebar display is controlled in this file. Multiple sidebars can be set up in functions.php, and contents of sidebar widgets are set up from the WordPress wp-admin panel.

footer.php

Contains instructions for global footer and closes HTML tags.

index.php – home

The index file controls what the homepage of your WordPress theme looks like. By default it is a loop that queries and then displays the most recent blog posts, with a link in the bottom to view previous posts.

Alternately, you can specify in wp-admin -> settings -> reading to have the home page be a page you created yourself in WordPress. In that case, you specify a different page/URL for the regular blog posts to appear on, and that page is generated by index.php.

single.php – individual posts

The display of individual posts in your WordPress theme is controlled by a little file called single.php. It contains a loop that queries just one post and displays it.

You can specify if you want sidebars (and which you want), if you want it to look different than the other pages on the site.

page.php – individual pages

Page.php controls what pages look like. You can choose to eliminate sidebars or other elements, add other unique elements for pages alone.

WordPress also allows you to create different page templates within your WordPress theme for different types of pages. To create a page template, simply copy page.php, rename it to whatever you want, then add this code to the top:

/*

Template Name: YourPageNameHere

*/

?>

archive.php, category.php, tag.php – archives

You can control the look and feel of different archives using template files also. If there is no archive file, the archives will look like index.php; however you can create an archive.php to override that. If you create a file called category.php, it will override archive.php for categories only. If you create a tag.php, you can override it for tag archives only.

The Loop

The loop is perhaps the most powerful part of your WordPress theme. It starts with a query (which determines which posts or pages to grab), and ends with a PHP “endwhile” statement. Everything in between is up to you. You can specify the output of titles, post content, metadata, custom fields and commenting all within the loop and each element is output for each post or page until the query is done. You can set up multiple loops and queries on a single page; for example: on a single.php you could have the loop showing the entire content of a single post, with a loop outputting just titles and thumbnails for related posts below it.

Query post or page

Start Loop

the_title (outputs the title of the post)

the_excerpt (outputs the post excerpt)

the_content (outputs the full post content)

the_category (outputs the post categories)

the_author (outputs the post author)

the_date (outputs the post date)

other tags (there is a variety of other tags you can use in the loop)

endwhile;

Exit the loop

Background files of a WordPress theme

In order for a WordPress theme to work, it needs a few essential background files. These files can be modified to your needs and can quite powerfully affect the custom look and functionality of your site.

comments.php

This controls the output of comments, which can be included in the loop if you desire comments on your theme. Comments.php can be overriden by plugins such as Disqus, which then take over comment functionality on your blog.

functions.php

Functions.php allows you to put your own custom PHP code in order to modify core elements of your theme. It is often used to specify multiple sidebars, change the number of characters in the excerpt or add custom admin panel options for wp-admin.

style.css

This is the main CSS stylesheet for your theme. It also contains text at the top which tells WordPress what the name of your WordPress theme is, who the author is and what the URL of your site is.

Step by step WordPress learning (Part 1)