Home > Backend Development > PHP Tutorial > How to introduce template files in WordPress theme production, wordpress template_PHP tutorial

How to introduce template files in WordPress theme production, wordpress template_PHP tutorial

WBOY
Release: 2016-07-12 09:02:20
Original
895 people have browsed it

How to introduce template files in WordPress theme production, wordpress template

get_template_part() is used to reference template files, similar to get_header(), get_sidebar() and get_footer(), But this get_template_part() can introduce files with custom names.

How to use

get_template_part( $slug, $name );
Copy after login

Parameters

$slug

(String) (required) The file name of the template to be imported, excluding the suffix .php, that is, if you need to import the loop.php file $slug in the current theme root directory, just fill in "loop".

Default: None

$name

(String) (optional) The sub-file name of the template file to be imported. If you want to import the loop-img.php file in the current theme root directory, fill in "loop" for the $slug parameter and "img" for the $name parameter. ".

Default value: None

Return value

This function has no return value.

Example

Introduce the endskin.com file in the current theme root directory:

get_template_part( 'endskin' );
Copy after login

Introduce the loop.php file in the current theme part directory:

get_template_part( 'part/loop' );
Copy after login

Introduce the endskin-com.php file in the current theme root directory:

get_template_part( 'endskin', 'com' );
Copy after login

Others

This function is located at: wp-includes/general-template.php

Articles you may be interested in:

  • Getting the header template and bottom template in WordPress theme writing
  • Explaining the PHP used to get the comment template and search form in WordPress Function

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1085875.htmlTechArticleHow to introduce template files in WordPress theme production, wordpress template get_template_part() is used to reference template files, similar to get_header (), get_sidebar() and get_footer(), just...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template