Through the last talk about the WordPress theme we know the two main documents are style.css and index.php, they are the most basic, but only they are obviously not perfect, although you can write all the features To index.php, but this does not meet the WordPress theme of the specification, this will learn how to follow the norms to create their own themes.
From the above icon we can see that a basic WordPress page is composed of four parts (header.php,
Index.php, footer.php, sidebar.php), they are responsible for different parts of the WordPress blog page. We will explain the following four courses in the production of these documents, today we have to look at how to make header.php file
(1) First, we write the index.php following a few simple functions, these functions do not explain the time, so when we talk about index.php file will be explained.
The code is as follows：
(2) and then in the wpc-tomheng directory to create a header.php file.
Write the following code:
<!DOCTYPE html PUBLIC ”-//W3C//DTD XHTML 1.0
<title> <?php bloginfo(‘name’); ?></title>
<linkrel=”stylesheet” href=”<?php bloginfo(’stylesheet_url’); ?>” type=”text/css” media=”screen”
<h1><a href=”<?php echo get_option(‘home’); ?>/”><?php bloginfo(‘name’); ?></a></h1>
<div class=”description”><?php bloginfo(‘description’); ?></div>
(3) open the browser to view the theme is not able to see the name of the blog shows there are descriptions. Well, this is the template function of the credit, and here we look at how this is achieved.
First, bloginfo () template function
Bloginfo () is a template function, through which we can call your blog-related information, we used header.php four times this function, remove the three main data: blog name bloginfo ( ‘name’), The style file bloginfo ( ‘stylesheet_url’), blog description bloginfo ( ‘description’).
There are two points to be noted:
1) Bloginfo () function with the output function, that he is not to return data, but directly to the data output to the browser.
2) Boginfo () output different data through the parameter configuration to achieve. Bloginfo () function of the common configuration parameters
Second, get_option () function
Here we use this function to get the address of the blog link, this function needs to pay attention to his return is a url address variable, so if you want to display on the page then need to add echo function in front of him. Of course, we should also add some styles, but this is beyond the scope of our tutorial, here I just explain to you how to use these template functions and theme production of basic methods, Knowledge, coupled with a wealth of creativity in order to achieve a beautiful theme, which depends on your CSS knowledge base and design capabilities and these are not included in the content of our tutorial (perhaps after wpc will provide the relevant tutorial, pay close attention)
(2) open the browser to view the theme is not able to see the blog shows the name of the description of it. Well, this is the template function of the credit, and here we look at how this is achieved.