Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2012
202
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3.  * Retrieve path of single template in current or parent template.
  4.  *
  5.  * @since 1.5.0
  6.  *
  7.  * @return string
  8.  */
  9. function get_single_template() {
  10.     $object = get_queried_object();
  11.  
  12.     $templates = array();
  13.  
  14.     $templates[] = "single-{$object->post_type}.php";
  15.     $templates[] = "single.php";
  16.  
  17.     return get_query_template( 'single', $templates );
  18. }
  19.  
  20.  
  21. /**
  22.  * Retrieve path to a template
  23.  *
  24.  * Used to quickly retrieve the path of a template without including the file
  25.  * extension. It will also check the parent theme, if the file exists, with
  26.  * the use of {@link locate_template()}. Allows for more generic template location
  27.  * without the use of the other get_*_template() functions.
  28.  *
  29.  * @since 1.5.0
  30.  *
  31.  * @param string $type Filename without extension.
  32.  * @param array $templates An optional list of template candidates
  33.  * @return string Full path to file.
  34.  */
  35. function get_query_template( $type, $templates = array() ) {
  36.     $type = preg_replace( '|[^a-z0-9-]+|', '', $type );
  37.  
  38.     if ( empty( $templates ) )
  39.         $templates = array("{$type}.php");
  40.  
  41.     return apply_filters( "{$type}_template", locate_template( $templates ) );
  42. }
Advertisement
RAW Paste Data Copied
Advertisement