How To Create A Wordpress Theme
How To Create A Wordpress Theme
How To Create A Wordpress Theme
CREATING A
WORDPRESS
THEME
CLASS 3
WHAT IS A WORDPRESS
THEME
• A Wordpress theme is simply a folder that contains of PHP,
CSS & images that are used as a “page wrap” for the
pages you create in the CMS.
/*
Theme Name: My Theme
Theme URI: http://blog.adam.co
Description: My First Wordpress Theme
Version: 1.0
Author: Adam Coulombe
Author URI: http://www.adam.co
*/
body {
padding-top: 48px;
ABOUT INDEX.PHP
• index.php is essentially an HTML file that will serve as the main
template for your theme.
~wordpress~/wp-content/themes/
how to link the css
• Traditionally, you may be used to seeing your stylesheet
being linked like so:
<link href="style.css" rel="stylesheet" type="text/css" />
• YOU COULD:
<img src="http://blog.adam.co/wp-content/themes/my-theme/images/myimage.jpg" />
• EVEN BETTER:
<img src="<?php bloginfo('template_directory'); ?>/images/myimage.jpg" />
Source: http://codex.wordpress.org/images/1/18/Template_Hierarchy.png
dividing your template
• Dividing your HTML into portions allows you to re-use common
portions of your HTML code that may appear in more than one
before after
<html> <?php get_header(); ?>
<head> <div id="content">...</div>
<title>My Template</title> <?php get_sidebar(); ?>
</head> <?php get_footer(); ?>
<body>
<div id="header">...</div>
<div id="content">...</div>
<div id="sidebar"></div>
<div id="footer">...</div>
</body>
</html>
The template tags <?php get_header(); ?>, <?php get_sidebar(); ?> and
<?php get_footer(); ?> are used to include their respective portions.