[WordPress] WordPress custom themes

Source: Internet
Author: User
Tags php template subdomain name wordpress blog wordpress version

WordPressEach topic must have at least two files-Style.cssAndIndex. php.

Index. php tells the topic how to layout all elements;

Style.css tells the topic how to display all elements and their styles.

Terms:

Template)

It is actually a code set, which is used in many places in the topic, so they are integrated into a template, so that you do not have to input the repeated code over and over again.

Template File)

One file contains one or more code sets (templates. Each topic is composed of multiple template files, such as index.php, style.css, and sidebar. php.

Theme or WordPress theme)

All files you are using: text, images, Code, etc. Note: WordPress theme and WordPress template (s) are two different theme, although some people think they are the same.

Post (log or article)

It is a simple entry of your blog, such as a page or a diary.

Page (Static Page)

A special post, which is not organized by category. It is different from other logs. Note: In Wordpress, page and page are two different things.

A complete list of objects contained in a topic:

Style.css

Index. php

Home. php

Single. php

Page. php

Archive. php

Category. php

Search. php

404. php

Comments. php

Comments-popup.php

Author. php

Date. php

It is the WordPress hierarchy. It is simple to show you. Once a file in your topic is lost, the WordPress theme system will use another template file.

In the preceding figure, we can locate the template file to know the importance of each topic file.

WordPress uses this hierarchy to find the corresponding template file display page, and how to deal with the corresponding file after the loss.

For example, if the archive. php template file (used to display the archive page) is lost, WordPress will use index. php to control how the archive page is displayed.

For example, if the single. php template file is lost, it will look for index. php.

Wordpress blogEach pageYesComposed of multiple template files:

Home page:

In, we can see the topic'sindex.phpIs composed of four template files:header.php,index.php,sidebar.phpAndfooter.php.

Single Log page:

At this time, the page will contain the four template files:header.php,single.php,sidebar.phpAnd footer.

Header Template File

This file usually containsTitle(Title) andDescription(Description ). And they are usually the same throughout the blog.

Index template file:

This template file contains yourLog title,Log Content(That is, the text and images of each log) andLogsOfMetadata(Metadata is the additional information of each log, such as the author, the log release time, the category, and the number of messages ).

Sidebar Template File

This template file is mainly used to control the blogPage List,CATEGORY list,Archive list,Link ListAndOther lists.

Footer template file:

Imageheader.phpSame as template files,footer.phpUsually, the page does not change. You can place anything here, but it is usuallyCopyright information.

Next, create a simple theme page.

First, create a folder named mythemes under WordPress/WP-content/themes, which is the topic folder.

Under the mythemesfolder, create two files: index.php and style.css.

Index. php content:

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2  3 

Where, the WordPress function bloginfo ():

Display your blog information. Most of the information displayed on the WordPress management interface is user information and information in general settings. It can be used anywhere in the template file. Generally, bloginfo () is used to output content directly in the browser. If you need to return a value in PHP, use get_bloginfo ().

Usage:

1 <? PHP bloginfo = ($ show)?>

$ Show(String) (optional) KEYWORDS of the information you need to output. Default Value: 'name'

  • 'Name'-The "site title" set in Settings> General is displayed ". This data is the "blogname" record retrieved from the wp_options data table.
  • 'Description'-Displays the subtitle set in Settings> General ". This data is the "blogdescription" record retrieved from the wp_options data table.
  • 'Wpurl'-Display the "WordPress address (URL)" set in Settings> General )". This data is the "siteurl" record retrieved from the wp_options data table. You can consider using site_url () Instead, especially when using the subdirectory path instead of using the subdomain name to configure multiple sites (bloginfo will return the URL of the root website, instead of the sub-site URL ).
  • 'Siteurl'/'URL'-The "site address (URL)" set in Settings> General is displayed )")". This data is the "home" record retrieved from the data table wp_options. You can use home_url () instead.
  • 'Admin _ email'-The "email address" set in Settings> General is displayed ". This data is the "admin_email" record retrieved from the data table wp_options.
  • 'Charset'-The "Page and feed encoding" set in Settings> General is displayed ". This data is the "blog_charset" record retrieved from the wp_options data table. (Note: 3.5.1 + seems to have no such option)
  • 'Version'-Display the Wordpress version you are currently using. This data is the value of $ wp_version retrieved in WP-DES/version. php.
  • 'Html _ type'-Display the content type in the WordPress HTML page (default: "text/html "). The "html_type" record retrieved from the data table wp_options. The topic and plug-in can overwrite the default value by using the pre_option_html_type filter.
  • 'Text _ direction'-Display the text direction of the WordPress HTML page. You can use is_rtl () instead.
  • 'Language'-Display the WordPress language.
  • 'Stylesheet _ url'-Display the path of the CSS file (usually style.css) of the currently used topic. You can use get_stylesheet_uri () instead.
  • 'Stylesheet _ directory'-Display the style table path of the currently used topic. You can use get_stylesheet_directory_uri () instead.
  • 'Template _ url'/'Template _ directory'-URL path of the current topic. In the subtopic, both get_bloginfo ('template _ url') and get_template () will return the parent topic directory. You can use get_template_directory_uri () (for parent topic directory) or get_stylesheet_directory_uri () (for sub-topic directory) instead.
  • 'Pingback _ url'-Display the URL of the advertised file XML-RPC (XMLRPC. php)
  • 'Atom _ url'-Display atom feed URL (/feed/atom)
  • 'Rdf _ url'-Display the URL of the RDF/RSS 1.0 feed (/feed/RFD ).
  • 'Rss _ url'-Display the RSS 0.92 feed URL (/feed/RSS ).
  • 'Rss2 _ url'-Display the RSS 2.0 feed URL (/feed ).
  • 'Comments _ atom_url'-Displays the atom feed URL (/comments/feed) of the comment ).
  • 'Comments _ rss2_url'-The RSS 2.0 feed URL (/comments/feed) of the comment is displayed ).

After saving, open the WordPress background interface. Open the appearance --> topic interface.

The new themes topic is displayed here. Click Enable.

Click to view the site.

Now there is no content in the body, so it is blank.

Add in Body

1 <? PHP bloginfo ('name');?>

Displays the "site title" set in Settings> General ".

Effect:

The next step is an artboard!

 

[WordPress] WordPress custom themes

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.