# Sử dụng locate\_template (ok)

```php
<?php  
    // Trong functions.php
    if ( $overridden_template = locate_template( 'some-template.php' ) ) {
       // locate_template() returns path to file
       // if either the child theme or the parent theme have overridden the template
       load_template( $overridden_template );
     } else {
       // If neither the child nor parent theme have overridden the template,
       // we load the template from the 'templates' sub-directory of the directory this file is in
       load_template( dirname( __FILE__ ) . '/templates/some-template.php' );
     }
?>
```

```php
<?php
Tạo file some-template.php
Bạn có thể không cần đoạn comment sau đây :)))
/**
* Template Name: Some
* @package WordPress
* @subpackage Twenty_Fourteen
* @since Twenty Fourteen 1.0
*/
echo "Lorem";
?>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learnphp.gitbook.io/learnphp/wordpress/su-dung-locate_template.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
