get_parent_theme_file_path

函式
get_parent_theme_file_path ( $file = '' )
引數
  • (string) $file Optional. File to return the path for in the template directory.
    Required:
    Default: (empty)
返回值
  • (string) The path of the file.
定義位置
相關方法
get_parent_theme_file_uriget_theme_file_pathwp_print_theme_file_treeget_theme_file_uriget_registered_theme_feature
引入
4.7.0
棄用
-

get_parent_theme_file_path函式是一個WordPress函式,用於檢索父主題目錄下的檔案路徑: 這個函式接受一個引數,即你要檢索的檔案的路徑的檔名: 該函式返回指定檔案的檔案路徑。

檢索父主題中的檔案路徑。

function get_parent_theme_file_path( $file = '' ) {
	$file = ltrim( $file, '/' );

	if ( empty( $file ) ) {
		$path = get_template_directory();
	} else {
		$path = get_template_directory() . '/' . $file;
	}

	/**
	 * Filters the path to a file in the parent theme.
	 *
	 * @since 4.7.0
	 *
	 * @param string $path The file path.
	 * @param string $file The requested file to search for.
	 */
	return apply_filters( 'parent_theme_file_path', $path, $file );
}

常見問題

FAQs
檢視更多 >