WordPress Theme Creation Tutorial 1: Theme Basic Files

Source: Internet
Author: User
Tags php template

In the simplest case, a WordPress theme consists of two files:

index.php------------------Main Templates

Style.css-------------------Main style sheet

The following are not required, but have a special meaning for the template list:

404.php 404 templates
Rtl.css If the reading direction of the website is from right to left, it will be automatically included.
comments.php Comment Template
single.php Article template. A separate article is called when it is displayed, and if the template does not exist it will be used index.php
single-<post-type>.php Customizing individual page templates such as: Single-books.php shows a custom article type of books article, if the template does not exist, it will be used index.php
page.php Page templates
category.php Category templates
tag.php Label templates
taxonomy.php The term template. Use when requesting a term for a custom taxonomy
author.php Author templates
date.php Date/Time Template
archive.php Archive template. A template that is used when querying categories, authors, or dates. It should be noted that the template will be category.php, author.php, date.php (if present)
search.php Search results Templates
attachment.php Templates to use when viewing individual attachments
image.php Picture attachment template, which will call this template when viewing a single picture, and if this template is not present, call the attachment.php template
sidebar.php Sidebar
header.php Top of
footer.php Bottom
function.php Stencil functions

Embedding method:

Includes header header, using Get_header ();

Includes side bar sidebar, using Get_sidebar ();

Contains the bottom footer, using get_footer ();

The search box contains the searching form, using Get_search_form ();

 

Create custom templates: Declare this template comment

<?php /* Template name:my */ ?>

Basic content of the file:

STYLE.CSS requires a valid subject information tag, such as: (Note that two different themes are not allowed to have the same representation, which can lead to a topic selection error.) )

/* Theme name:youjiuyoutheme uri:http://youjiuyou.cn/description:the default Theme for WordPress.Author:tinyphp Author uri:http://youjiuyou.cn/version:1.0tags:black, Blue, white, two-columns, Fixed-width, Custom-header, Custom-background, Threaded-comments, Sticky-post, Translation-ready, microformats, Rtl-language-support, Editor-style, Custom-menu (optional) license:license uri:general Comments (optional). */

Header document (header.php)

<!DOCTYPE HTML><HTML<?php language_attributes ();?>><Head>        <MetaCharSet= "<?php bloginfo (' CharSet ');?>" />        <title><?php wp_title ();?></title>        <Metaname= "description"content= "<?php bloginfo (' description ');?>">        <Linkrel= "Profile"href= "HTTP://GMPG.ORG/XFN/11" />        <Linkrel= "stylesheet"href= "<?php echo Get_stylesheet_uri ();?>"type= "Text/css"Media= "Screen" />        <Linkrel= "Pingback"href= "<?php bloginfo (' Pingback_url ');?>" />        <?php if (is_singular () && get_option (' thread_comments ')) wp_enqueue_script (' comment-reply ');?>        <?php wp_head ();?>    </Head>

Use Bloginfo () settings <meta> character sets and description elements

Use Wp_title () settings <title> elements

Use Get_stylesheet_uri () to get the style sheet file for the current theme

Add a feed link using Automatic feed links

Add a declaration wp_head () to the front of the

Search results (search.php)

Use The_search_query () or Get_search_query () (To display or return a value

Installation:

Theme preview: Named Screenshot.png, placed under the root of your theme.

Theme installation: Add theme in background appearance, upload the. zip theme and edit it in the background.

After the WordPress theme is installed, the directory is located in wp-content/themes/

Basic Theme Pack Download >>

WordPress Theme Creation Tutorial 1: Theme Basic Files

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.