WordPress Technology & Digital Applications 2 — Questions and Answers
Question 1: Which WordPress function returns the URL of the current site's home page?
- get_site_url()
- home_url() (Correct answer)
- get_permalink()
- site_url()
Correct answer: home_url()
home_url() returns the URL set as the 'Site Address (URL)' in WordPress Settings, which may differ from site_url().
Question 2: What is the purpose of the WordPress REST API?
- To manage database backups automatically
- To allow external applications to interact with WordPress data via HTTP requests (Correct answer)
- To speed up page rendering on the server
- To handle WordPress multisite network requests
Correct answer: To allow external applications to interact with WordPress data via HTTP requests
The REST API exposes WordPress data as JSON endpoints so external apps, mobile clients, and JavaScript frontends can read and write content.
Question 3: Which file in a WordPress theme controls the layout of individual blog posts?
- page.php
- archive.php
- single.php (Correct answer)
- content.php
Correct answer: single.php
single.php is the template used for displaying a single post's full content in WordPress themes.
Question 4: What does the WordPress function wp_enqueue_script() do?
- Executes a PHP script immediately
- Registers and queues a JavaScript file to be loaded safely (Correct answer)
- Minifies JavaScript files for production
- Loads a script only for logged-in users
Correct answer: Registers and queues a JavaScript file to be loaded safely
wp_enqueue_script() is the proper way to add JavaScript files in WordPress, ensuring dependencies load in the correct order.
Question 5: In WordPress, what is a 'nonce' used for?
- Caching database query results
- Encrypting user passwords
- Verifying that a form submission or URL request is intentional and from the correct source (Correct answer)
- Generating unique post slugs
Correct answer: Verifying that a form submission or URL request is intentional and from the correct source
A nonce (number used once) is a security token that protects WordPress forms and URLs from CSRF attacks.
Question 6: Which WordPress hook fires immediately before WordPress redirects to the login page?
- init
- wp_login
- auth_redirect (Correct answer)
- login_init
Correct answer: auth_redirect
auth_redirect() is the function (called as a hook) that checks user authentication and redirects to the login page if needed.
Question 7: What is the default WordPress database table prefix?
- word_
- wp_ (Correct answer)
- wpress_
- wpdb_
Correct answer: wp_
WordPress uses wp_ as the default table prefix, which can be changed in wp-config.php for added security.
Which WordPress function returns the URL of the current site's home page?