May 2017
Beginner to intermediate
536 pages
14h 25m
English
WordPress uses a function called get_template_part for reusing templates as pure PHP files. This function locates the given template parts inside your theme files and makes a file inclusion under the hood. Consider the following code for understanding the use of the get_template_part function:
get_template_part( $slug, $name );
The first parameter, $slug, is mandatory, and it is used to load the main template. The second parameter, $name, is optional, and it is used to load a specialized version of the template. Let's look at some different usages of this function:
get_template_part("topic"); get_template_part("topic", "wordpress");
The first line of code will include the topic.php file inside the ...
Read now
Unlock full access