Wordpress function introduction get_template_part ()

Source: Internet
Author: User
A new function get_template_part () is added from 3.0. you can include another file in the current file as its file block.

A new function get_template_part () is added from 3.0. you can include another file in the current file as its file block.
Unlike the get_header () get_footer () get_siderbar functions, these functions also add other functions, such as widgets.
Get_template_part () is only a text block containing html and php and does not hook other content.

$ Loop_slug = 'news ';
As a result, this page contains the loop-news.php
In this way, you can create reusable blocks. for example, you need to display fixed-category articles on the sidebar.

In addition, sometimes our classification framework remains unchanged, while the style of the loop content changes. for example, we only need to display the title for news classification, the product category requires a thumbnail, so that we can use the get_template_part function to call different loop files to complete different display styles when judging that the current category is certain.

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.