Professional Documents
Culture Documents
GRAP362
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. A bare mininum Wordpress theme consists of AT LEAST the following:
ABOUT STYLE.CSS
style.css will serve as your main stylesheet, exactly like you have done in the past The filename must be called style.css style.css must contain a comment stating various information about your theme at the top of the document, before any styles.
/* 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. It must have the .php extension because it will contain template tags wherever dynamic content is to be placed
<?php the_author(); ?> <?php the_permalink(); ?> Outputs the name of the pages author Outputs the url of the current page
SAMPLE LOOP
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> <h1><?php the_title(); ?></h1> <?php the_content(); ?> <?php endwhile; endif; ?>
~wordpress~/wp-content/themes/
For your wordpress template, you must use the appropriate template tag to ensure your stylesheet is linked properly:
<link href="<?php bloginfo('stylesheet_url'); ?>" rel="stylesheet" type="text/css" />
images broken?
The images are located in this folder: CASE:
blog.adam.co/wp-content/themes/my-theme/images
ou need to provide the correct image path so they Y can be accessed from any page! 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
It is convention to separate the HTML portions of your header, sidebar and footer into their own php files, respectively.
before
<html> <head> <title>My Template</title> </head> <body>
after
</html>
</body>
The template tags <?php get_header(); ?>, <?php get_sidebar(); ?> and <?php get_footer(); ?> are used to include their respective portions.