Including Additional Files

WordPress 3.0 includes a new include function, get_template_part(). This function can take two arguments. Listing 6-20 shows two uses of this function.

Listing6-20. Using theget_template_part function get_template_part('loop'); // loop.php get_template_part('loop', 'index'); // loop-index.php

With the get_template_part() function, you can create your own hierarchy of included files that works just like the sidebars. With one argument, the slug, the function will include a filename matching that slug. If a second argument, the name, is included, WordPress will first look for slug-name.php, and if it doesn't exist, it will substitute the more generic slug.php file.

0 0

Post a comment