locate_template [ WordPress Function ]
locate_template ( $template_names, $load = false, $require_once = true )
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Soorgelijke functies: load_template, get_date_template, get_template, get_category_template, is_page_template
Retrieve the name of the highest priority template file that exists.
Searches in the STYLESHEETPATH before TEMPLATEPATH so that themes which inherit from a parent theme can just overload one file.
Source
<?php
function locate_template($template_names, $load = false, $require_once = true ) {
$located = '';
foreach ( (array) $template_names as $template_name ) {
if ( !$template_name )
continue;
if ( file_exists(STYLESHEETPATH . '/' . $template_name)) {
$located = STYLESHEETPATH . '/' . $template_name;
break;
} else if ( file_exists(TEMPLATEPATH . '/' . $template_name) ) {
$located = TEMPLATEPATH . '/' . $template_name;
break;
}
}
if ( $load && '' != $located )
load_template( $located, $require_once );
return $located;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- Function Reference/locate template « WordPress Codex
Description. Retrieve the name of the highest priority template file that exists. Searches in the STYLESHEETPATH before TEMPLATEPATH so that themes which ...
codex.wordpress.org - WordPress › Support » Hook load_template or locate_template
6 days ago ... Hook load_template or locate_template (1 post). Steveorevo Member Posted 12 hours ago #. This would excellent. Child development of ...
wordpress.org - Use locate_template instead of TEMPLATEPATH to Include Files in ...
Jan 14, 2010 ... Today I ran into an interesting problem while developing a BuddyPress theme. I was attempting to include a custom sidebar using PHP's ...
www.themightymo.com - 5 Ways To Include Template Files In WordPress - Deluxe Blog Tips
Jun 30, 2010 ... To check file existence, we can use locate_template() . This function allows us not only to retrieve file path, but also (optional) to include that file, ...
www.deluxeblogtips.com