Anatomy of A WordPress Themes

A while ago, we introduced to you the concept of creating a WordPress theme from HTML. We split the tutorial into two parts, and you can check out the first installation here and the second here. Today we are all about fleshing out the two tutorials, so feel free to regard this post as the third serving in the post series. My objective is to take apart the WordPress theme to give you a clear picture of how it (the theme) works.

This post assumes you have a working knowledge of HTML and CSS. I will go ahead and declare that having HTML and CSS skills is a prerequisite in designing WordPress themes. One more thing, this post will stay clear of big words and difficult concepts – it will be easy to comprehend, so be ready to have fun and learn.

A Little HTML Priming

Every HTML web page is split into different parts using the <div> tag. For instance, you can break the body (<body>) of your website into several sections such as navigation, header, main content, sidebar and footer amongst others.

Once you have your web page in sections, you can order (or arrange) the sections as you wish using CSS. This process is known as styling, and it involves adding other style elements such as color, size, borders, special effects etc. Such is the power of CSS, which – by the way – is short for Cascading Style Sheets. When you put your HTMl and CSS files together and throw in a couple of images, you end up with a complete website.

Static HTML web pages are split into divisions (what we called sections earlier on) using <div> tags (or tables if you’re really old school). On the other hand, WordPress themes are split into different php files, which are then put back together using template tags.

Therefore, instead of having all body elements (header, main content, sidebar, footer etc) living in a single file (as is the case with static HTML), each of the body elements (in WordPress themes) lives in a separate files.

So, the header will live in header.php, the sidebar will find home in sidebar.php, the main content will live in index.php, or single.php (if it’s a post) or page.php (if it’s a page). The footer section will live in footer.php and so on.

THEMATIC (CHILD) THEMES

Thematic uses Child Themes, these are essentially stripped down versions of a full WP theme, that needs the Thematic Framework for functionality. Upon download, Thematic comes packaged with a basic child theme, but you can download many more from the Thematic homepage. Download Thematic Child Themes.

Below, you will find a small selection of themes available for Thematic.

Tambuwal: Four million residents in danger as Goronyo Dam shrinks

Sokoto State Governor, Aminu Tambuwal, yesterday urged stakeholders in the state to work together to tackle problem of water shortage at Goronyo Dam, the level of which had shrunk by almost 90 per cent.

The dam had served as the primary source of water for close to four million people in Sokoto and Kebbi states in the North West part of the country. Water from the dam was often used for domestic and irrigation purposes in the two affected states.

Speaking when he led officials on an inspection visit to the dam, Tambuwal said the depletion of the dam’s water level was alarming.

“The reservoir of Goronyo Dam was constructed to hold one billion cubic metres of water but as we’ve seen today, the water in it is just about 100 million cubic metres. “This has resulted in inadequate supply of water to our water board and in effect, we had to resort to rationing water to the people. “Our farmers are also suffering because output from this year’s dry season farming will invariably be affected.”

Migrating A Website To WordPress

Now powering over 17% of the Web, WordPress is increasingly becoming the content management system (CMS) of choice for the average user. But what about websites built with an outdated CMS or without a CMS at all? Does moving to WordPress mean starting over and losing all the time, energy and money put into the current website? Nope!

Migrating a website (including the design) over to WordPress is actually easier than you might think. In this guide, we’ll outline the migration process and work through the steps with a sample project. We’ll also cover some of the challenges you might encounter and review the solutions.

WordPress Themes

About This Guide

Before we get to work, let’s establish some context. First, this guide was written primarily with beginners in mind and will be most helpful for basic websites. Some of you will likely encounter advanced aspects of WordPress migration, but they are beyond the scope of this guide. If you’re tackling an advanced migration and get stuck, feel free to share your difficulty in the comments below.

OBJECTIVES

The objective of this guide is to help you with the following:

Plan an effective migration to WordPress.

Walk through the technical steps involved in migrating.

Get ideas and resources to solve common migration challenges.

WordPress Themes

ASSUMPTIONS

I assume you have basic familiarity with WordPress. Previous development experience with WordPress would be helpful, but not necessary. I also assume you have an existing website and design that you want to migrate to WordPress.

BASIC STEPS

Here are the basic steps that I recommend you follow for a typical WordPress migration:

Evaluate website.
Work carefully through the pages on your existing website, identifying all of the types of content (standard pages, photo galleries, resource pages, etc.) and noting any areas that need special attention.

Set up environment.
Set up WordPress and get ready to import.

Import content.
Bring over and organize your content, whether via an importing tool, manual entry (for a small amount, when no tool is available) or a custom importing process.

EXISTING FUNCTIONALITY

Do any forms need to be migrated (contact forms, application forms, etc.)?

Is access to any content restricted (such as members-only content)?

Does the website sell products (digital or physical)?

Do any administrative tools need to be carried over (such as custom CMS functionality)?

WordPress Themes

A WORKING EXAMPLE

My brother, Joshua Wold, has volunteered a website to serve as an example; it’s for a side project of his in which he sells posters and postcards of a Vegan Food Pyramid. He built the website in plain HTML, with some basic PHP includes for the header and footer. Below is a screencast of me evaluating the website to give you a sense of how the process will work. Enjoy!

Set Up WordPress

Before importing the content, we need to get WordPress ready to go. If you’re just experimenting or if you prefer offline development, start with a local installation of WordPress. Otherwise, the next step is to install WordPress with your current hosting provider; or you could use the migration process as a great opportunity to move to a new host.

Once WordPress is up and running, you’re ready for action!

WordPress Themes

For our example, we’ve installed WordPress with the same host, setting it up in a wp directory for the duration of the migration process.

SETTINGS AND PLUGINS

With WordPress Themes installed, we’ll make a few minor adjustments:

Update permalinks.
Go to Settings → Permalinks to make changes. In most cases, I’ll switch to “postname”-style permalinks.

Update users.
I create an admin-level account for myself and any admin or editor accounts that are needed for clients and collaborators. I also remove the default “admin” user name if it exists (a basic but wise step for WordPress security).

Depending on the needs of the project, we might have to preinstall plugins. Here are the major categories of plugins:

Form management
Migrating a form “as is” is usually a mess; simply recreating it using a forms plugin is usually easier. My current favorite is Gravity Forms ($39+ per license). Other options are Formidable (with free and pro versions) and Contact Form 7 (entirely free).

SEO management
Search engine optimization (SEO) is a touchy subject. My philosophy is to build content for people, not for search engines. That being said, there is a common-sense approach to SEO that is solidly supported by the WordPress plugin ecosystem. And if your old website includes custom meta descriptions, giving them a new home during the importing process is important. I recommendWordPress SEO (free).

Multiple languages
If your old website supports multiple languages, WordPress has you covered. My plugin of choice is WPML ($79 per license, free for non-profits). Another option isqTranslate (free).

Security
WordPress security is a topic near and dear to me. The increasing popularity of WordPress has made it a target for security attacks. WordPress itself is rarely the problem; a poorly secured hosting environment or an outdated or poorly developed plugin usually is. I use managed WordPress hosting for the majority of my projects, which offers a good foundation for solid WordPress security. Options include WPEngine, ZippyKid, Pagely and Synthesis. In addition to managed hosting (and especially if you opt for a non-managed host), consider installing a security plugin, such as Better WP Security (free) or Wordfence (also free). Last but not least, review the “Hardening WordPress” guide in the Codex.

Backups
If you opt for managed hosting, backups are usually included (make sure, though). If you’re managing backups yourself or you want an extra layer of data protection, great options are available, including VaultPress ($15+ a month), CodeGuard ($5+ a month), BackupBuddy ($75+ per license) and BackWPup (free).

Create A Tab Widget In WordPress

In this WordPress tutorial, you’ll learn how to create the Tabber widget, which is very useful for when multiple widgets need to fit in a sidebar. It saves space and streamlines the appearance and functionality of your WordPress-powered website.

In the past, there were different methods of doing this, most of which were theme-dependent. As we’ll see in this tutorial, creating a tabbed widget that works on its own and with any theme is easily accomplished. So, let’s jump in and learn how to create our own Tabber widget, which we’ve made available for downloading at the end of this article.

Saving Sidebar Space

The main advantage of tabs is that you can fit more widgets into the sidebar. And tabs look good. The image below shows how much vertical space is taken up by three standard widgets (using the default Twenty Ten theme). The default layout is on the left, and our tabber widget is on the right:

Before We Start

A few things are useful to know. Because we are building a widget in this article, you might want to learn about WordPress’ Widgets API and how to create a basic widget:

The Basic Idea

The idea for this widget is simple: select a sidebar, and the Tabber widget will grab all of its widgets and display them as tabs. In the widget’s interface, you can select a sidebar, specify an extra CSS class and optionally apply your own styles. When enabled, the plugin will register an extra sidebar (which may be removed if you have other ways to add a sidebar). Then, using the same code, you can add more sidebars, and each of them can hold instances of the Tabber widget.

To control your widgets, Tabber uses idTabs for jQuery, created by Sean Catchpole, but you could always use another solution. Note that additional CSS is loaded to style the resulting widget.

So, the goal with Tabber is to transform any widget’s output into markup that can be used to display tabs

tags for this. Other themes may use complicated markup that can’t be predicted or successfully transformed into the output needed for tabs.

The solution to this problem is to intercept the widget’s parameters before rendering, and then to restructure them into useful structures using JavaScript or jQuery for the tabbed output. More on that later.

action. We register the widget on line 17.

Widget interface.

The Main Tabber Widget Class

Tabber is a normal widget, and in this case it is located

SETTINGS: PLUGIN INTERFACE

The widget has two settings:

“sidebar”
to hold the ID of the selected sidebar

“css”
for extra CSS classes to style the Tabber widget

When selecting which sidebar to use, you must avoid using the sidebar that holds the Tabber widget. Otherwise, it will spin into endless recursion. To avoid this, before rendering the widget’s content, check whether the selected sidebar is the same as the parent sidebar. This can’t be prevented while the widget is set up, because the widget’s panel affords very little control over this.

Also, using sidebars that are not normally used is a good idea. To help with this, the plugin includes sample code to help you add an extra sidebar.

This function requires the name of the sidebar, and it will display all widgets in it. Line 9 contains the check mentioned before, to prevent recursion when displaying sidebar content if the selected sidebar is the same as the parent sidebar.

Lastly, the filter is removed, and any widgets belonging to other sidebars are displayed normally, without modification.

WIDGET MODIFICATION

To prepare for the transformation done with JavaScript, the tabber widget includes the

tag for the control tabs. After this filter, the widget’s output will look like this:

JavaScript For Widget Transformation

Once the widget’s presentation is modified, one thing remains: to complete the transformation and get the titles from the widgets and turn them into tabs:This code uses jQuery to get all of the Tabber widgets based on the

will hold only its content.

Final Tabber example.

Finally, when all this is done, we enable idTabs to activate the tabs control. And with the default styling loaded from the

How To Install The Tabber Plugin

As with any other plugin, unpack it, upload it to WordPress’ plugins folder, and activate it from the plugins panel. When you go to the “Widgets” panel, you will see an additional sidebar, “Tabber Example Sidebar,” at the end on the right. And “Available Widgets” will show one more widget, “D4P Smashing Tabber.”

Add this new widget to the “Main Sidebar.” From the “Sidebar” widget drop-down menu, select “Tabber Example Sidebar,” and save the widget. Now, open the “Tabber Example Sidebar” and add the widgets you want to be displayed as tabs. You can add as many widgets as you want, but pay attention because if you add too many, the tab’s control will break to two or more lines, and it will not look pretty. Starting with two or three widgets is best.

Conclusion

Creating one widget to display several other widgets as a tab isn’t very difficult, as you can see. The trick is in adjusting the widgets’ output to a format that can be transformed into tabs, and then using JavaScript to display them. We’ve explored just one possible transformation method; you can always experiment with ways to rearrange widget elements.

We used idTabs here, but there are many methods of displaying tabs, and not all of them require JavaScript:

I prefer using a jQuery-based solution, and idTabs is very easy to use and easy to style and it works in all browsers. Check out other solutions, and see what extra features they offer to enhance your own tabbed widgets.

from : http://www.smashingmagazine.com/2014/08/27/a-tour-of-wordpress-4-0/