Home > Backend Development > PHP Tutorial > How to introduce template files in WordPress theme production

How to introduce template files in WordPress theme production

WBOY
Release: 2016-07-29 09:08:42
Original
1019 people have browsed it

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

Usage

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

Parameters

$slug

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

Default: None

$name

(String) (optional) The sub-file name of the template file to be imported. If you want to introduce the loop-img.php file in the current theme root directory, fill in the $slug parameter with "loop" ", fill in "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

The above introduces the introduction method of template files for WordPress theme production, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

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