首页 WordPress函数大全 get_template_part()

get_template_part()

2020-05-01 / 3530阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

get_template_part( string $slug, string $name = null )

Loads a template part into a template.

描述

Provides a simple mechanism for child themes to overload reusable sections of code in the theme.

Includes the named template part for a theme or if a name is specified then a specialised part will be included. If the theme contains no {slug}.php file then no template will be included.

The template is included using require, not require_once, so you may include the same template part multiple times.

For the $name parameter, if the file is called "{slug}-special.php" then specify "special".

参数

$slug

(string)
(Required)
The slug name for the generic template.

$name

(string)
(Optional)
The name of the specialised template.

Default value: null

大家谈论
    我的见解