Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct Q38 layout #5243

Merged
merged 9 commits into from
Dec 18, 2022
21 changes: 14 additions & 7 deletions wordpress/wordpress-quiz.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,19 +324,24 @@ if ( ! defined( 'ABSPATH' ) ) {

#### Q38. How can you add a custom script that needs to run only on the contact page of a site? The slug of the page is contact.

- [ ] Link to the script directly from a template named page-contact.php using the get_header() template tag, like this:
```
Link to the script directly from a template named page-contact.php using the get_header() template tag, like this:
get_header( '<script src="/my-script.js"></script>' );
Use functions.php to conditionally load the script by hooking it to wp_enqueue_scripts(), like this:
```

- [ ] Use functions.php to conditionally load the script by hooking it to wp_enqueue_scripts(), like this:
```
add_action( 'wp_enqueue_scripts', 'load_scripts' );

function load_scripts() {
if ( is_page( 'contact' ) ) {
echo '<script src="/my-script.js"></script>';
}
}
```

Use functions.php to conditionally load the script by hooking it to wp_enqueue_scripts(), like this:
- [ ] Use functions.php to conditionally load the script by hooking it to wp_enqueue_scripts(), like this:
```
add_action( 'wp_enqueue_scripts', 'load_scripts' );
function load_scripts() {
if ( is_page( 'contact' ) ) {
Expand All @@ -345,10 +350,12 @@ add_action( 'wp_enqueue_scripts', 'load_scripts' );
}
```

- [ ] Link to the script directly from a template named page-contact.php, like this:
- [ ] `<head>`
- [x] `<script src="/my-script.js"></script>`
- [ ] `</head>`
- [x] Link to the script directly from a template named page-contact.php, like this:
```
<head>
<script src="/my-script.js"></script>
</head>
```

#### Q39. Where can you find the official WordPress documentation and usage guide?

Expand Down