WordPress WordPress Theme Development & Customization 2 — Questions and Answers
Question 1: Which function allows a WordPress theme to add support for featured images?
- add_theme_support('post-thumbnails') (Correct answer)
- add_image_support()
- enable_featured_image()
- register_thumbnail()
Correct answer: add_theme_support('post-thumbnails')
add_theme_support('post-thumbnails') enables the featured image metabox and functions in the theme.
Question 2: What is a child theme in WordPress used for?
- Customizing a parent theme without modifying its core files (Correct answer)
- Creating a subdomain website
- Building a new theme from scratch
- Installing plugins safely
Correct answer: Customizing a parent theme without modifying its core files
A child theme inherits the parent theme's functionality while allowing safe customizations that survive parent theme updates.
Question 3: Which file is required in every WordPress child theme?
- style.css (Correct answer)
- functions.php
- index.php
- header.php
Correct answer: style.css
A child theme must have a style.css file with a 'Template' header pointing to the parent theme.
Question 4: What WordPress function outputs the URL of the current theme directory?
- get_template_directory_uri() (Correct answer)
- get_theme_url()
- theme_path()
- wp_theme_dir()
Correct answer: get_template_directory_uri()
get_template_directory_uri() returns the URL to the active theme's directory, useful for referencing assets.
Question 5: In WordPress theme development, what is the purpose of the functions.php file?
- To add custom functionality and hooks to the theme (Correct answer)
- To define page templates only
- To store database queries
- To register navigation menus exclusively
Correct answer: To add custom functionality and hooks to the theme
functions.php acts as a plugin for the theme, allowing you to add features, register sidebars, enqueue assets, and hook into WordPress.
Question 6: Which WordPress function registers a navigation menu location in a theme?
- register_nav_menus() (Correct answer)
- add_nav_menu()
- create_menu_location()
- wp_nav_menu_register()
Correct answer: register_nav_menus()
register_nav_menus() defines one or more menu locations that can be assigned from the WordPress Menus admin panel.
Which function allows a WordPress theme to add support for featured images?