WordPress Theme Template hierarchy and common template functions

Source: Internet
Author: User
Tags date functions header php software version wordpress version

WordPress is currently the world's most widely used blog system, is an open source of PHP software. Because the user is numerous, so the WordPress community is very active, has the rich plug-in template resources. Use WordPress can quickly build independent blog site. Many well-known science and technology blog is also built by WordPress, such as: Lei Feng nets, titanium media. The following PHP site for WordPress Theme developers sorted out the necessary knowledge to make WordPress theme.
wordpress Theme Template Hierarchy
Home:

    1. home.php
    2. index.php


article page:

    1. single-{post_type}.php– if the article type is videos (ie video), WordPress will go to find single-videos.php (WordPress 3.0 and above version support)
    2. single.php
    3. index.php


page:

    1. Custom template – Where the page is created in WordPress background, the right-hand sidebar can select a custom template for the page
    2. page-{slug}.php– if the page's thumbnail name is news,wordpress will look for page-news.php (WordPress 2.9 and above version support)
    3. page-{id}.php– If the page ID is 6,wordpress will look for page-6.php
    4. page.php
    5. index.php


Category:

    1. category-{slug}.php– if the abbreviated name of the category is news,wordpress will look for category-news.php (WordPress 2.9 and above version support)
    2. category-{id}.php-If the category ID is 6,wordpress will look for category-6.php
    3. category.php
    4. archive.php
    5. index.php


label

    1. tag-{slug}.php– if the label name is Sometag,wordpress, it will look for tag-sometag.php
    2. tag-{id}.php– If the label ID is 6,wordpress will look for tag-6.php (WordPress 2.9 and above version support)
    3. tag.php
    4. archive.php
    5. index.php


Author:

    1. author-{nicename}.php– If the author's nickname is Rami,wordpress will look for author-rami.php (WordPress 3.0 and above version support)
    2. author-{id}.php– If the author ID is 6,wordpress will look for author-6.php (WordPress 3.0 and above version support)
    3. author.php
    4. archive.php
    5. index.php


Date page:

    1. date.php
    2. archive.php
    3. index.php


Search Results:

    1. search.php
    2. index.php


404 (Not found) page

    1. 404.php
    2. index.php


Attachment page:

    1. mime_type.php– can be any MIME type (image.php, video.php, audio.php, application.php, or others).
    2. attachment.php
    3. single.php
    4. index.php


WordPress Theme – Judge Tag
Is_home (): Is the home page
Is_single (): Is a content page (Post)
Is_page (): Is the Content page (page)
Is_category (): Is category/archive page
Is_tag (): Is the Tag archive page
Is_date (): archive page for specified date
Is_year (): Archive page for a specified year
Is_month (): Whether to archive pages for a specified month
Is_day (): Archive page for the specified day
Is_time (): archive page for specified time
Is_archive (): Is an archive page
Is_search (): Is the search results page
Is_404 (): Is an "HTTP 404:not Found" error page
Is_paged (): Homepage/category/archive page is displayed on multiple pages
Judge tag is often used in WordPress theme sidebar (sidebar.php) template file
WordPress Theme –header Common PHP functions
<?php bloginfo (' name ');?>: Blog name (title)
<?php bloginfo (' Stylesheet_url ');?>: CSS file path
<?php bloginfo (' Pingback_url ');?>: Pingback URL
<?php bloginfo (' Template_url ');?>: Template file path
<?php bloginfo (' version ');?>: WordPress version
<?php bloginfo (' Atom_url ');?>: Atom URL
<?php bloginfo (' Rss2_url ');?>: RSS 2.o URL
<?php bloginfo (' url ');?>: Blog URL
<?php bloginfo (' Html_type ');?>: Blog page HTML type
<?php bloginfo (' CharSet ');?>: Blog page encoding
<?php bloginfo (' description ');?>: Blog description
<?php wp_title ();?>: Title of a specific content page (Post/page)
WordPress Theme – templates commonly used PHP functions
<?php Get_header ();?>: Calling Header Template
<?php Get_sidebar ();?>: Calling sidebar template
<?php Get_footer ();?>: Calling footer Template
<?php the_content ();?>: Display content (Post/page)
<?php if (have_posts ())?>: Check for presence Post/page
<?php while (have_posts ()) "The_post ()?>: Display if there is post/page
<?php endwhile?>: While end
<?php endif?>: If End
<?php the_time (' string ')?>: Display time, time format is determined by "string" parameter, specific reference PHP manual
<?php Comments_popup_link ();?>: Message link in the body. If you use Comments_popup_script (), the message opens in a new window and, conversely, opens in the current window
<?php the_title ();?>: Content page (post/page) title
<?php The_permalink ()?>: Content page (post/page) Url
<?php the_category (', ')?>: A specific content page (Post/page) belongs to category
<?php The_author ();?>: Author
<?php the_id ();?>: Specific content page (post/page) ID
<?php Edit_post_link ()?>: If the user is logged in and has permission to display the edit link
<?php get_links_list ();?>: displaying links in Blogroll
<?php comments_template ();?>: Calling message/reply template
<?php wp_list_pages ();?>: Show Page List
<?php wp_list_categories ();?>: Display Categories list
<?php next_post_link ('%link ');?>: Next article link
<?php previous_post_link ('%link ');?>: previous article link
<?php Get_calendar ();?>: Calendar
<?php wp_get_archives ()?>: Display content Archive
<?php Posts_nav_link ();?>: navigation, displaying previous/next post links
<?php include (TemplatePath. '/filename ');?>: Embed other files, can be customized templates or other types of files
WordPress Theme – Other functions related to templates
<?php _e (' message ');?>: output appropriate information
<?php Wp_register ();?>: Show Registered Links
<?php wp_loginout ();?>: Show Logon/Logoff links
<!–next page->: Paging the current content
<!–more–>: Truncate the current content to not display all content on the home page/catalog pages
<?php timer_stop (1);?>: Web Load Time (sec)
<?php Echo get_num_queries (): Page load Query volume
Reprint please indicate the source: http://www.php-z.com/753.html



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.