get_parent_theme_file_path

Retrieves the path of a file in the parent theme.

Description

(string) get_parent_theme_file_path( (string) $file = '' ); 

Returns (string)

The path of the file.

Parameters (1)

0. $file — Optional. (string) => ''
File to return the path for in the template directory.

Usage

  1. if ( !function_exists( 'get_parent_theme_file_path' ) ) { 
  2. require_once ABSPATH . WPINC . '/link-template.php'; 
  3.  
  4. // Optional. File to return the path for in the template directory. 
  5. $file = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_parent_theme_file_path($file); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/link-template.php  
  1. function get_parent_theme_file_path( $file = '' ) { 
  2. $file = ltrim( $file, '/' ); 
  3.  
  4. if ( empty( $file ) ) { 
  5. } else { 
  6. $path = get_template_directory() . '/' . $file; 
  7.  
  8. /** 
  9. * Filters the path to a file in the parent theme. 
  10. * @since 4.7.0 
  11. * @param string $path The file path. 
  12. * @param string $file The requested file to search for. 
  13. */ 
  14. return apply_filters( 'parent_theme_file_path', $path, $file );