Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Retrieve path of single template in current or parent template.
- *
- * @since 1.5.0
- *
- * @return string
- */
- function get_single_template() {
- $object = get_queried_object();
- $templates = array();
- $templates[] = "single-{$object->post_type}.php";
- $templates[] = "single.php";
- return get_query_template( 'single', $templates );
- }
- /**
- * Retrieve path to a template
- *
- * Used to quickly retrieve the path of a template without including the file
- * extension. It will also check the parent theme, if the file exists, with
- * the use of {@link locate_template()}. Allows for more generic template location
- * without the use of the other get_*_template() functions.
- *
- * @since 1.5.0
- *
- * @param string $type Filename without extension.
- * @param array $templates An optional list of template candidates
- * @return string Full path to file.
- */
- function get_query_template( $type, $templates = array() ) {
- $type = preg_replace( '|[^a-z0-9-]+|', '', $type );
- if ( empty( $templates ) )
- $templates = array("{$type}.php");
- return apply_filters( "{$type}_template", locate_template( $templates ) );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement