WordPress interview questions answer for preparation

Here are 100 WordPress interview questions and answers, covering core concepts, theme development, plugin development, hooks, database, security, performance, and best practices. Each question is in bold, followed by a detailed answer. No dividing lines.

What is WordPress and what are its main features?
Answer: WordPress is a free, open‑source content management system (CMS) written in PHP and using MySQL/MariaDB. Main features: user management, media management, theme system, plugin architecture, SEO‑friendly, multilingual support, REST API, custom post types, and a large ecosystem of themes and plugins.

What is the difference between WordPress.com and WordPress.org?
Answer: WordPress.org is the self‑hosted version where you download the software, host it on your own server, and have full control over themes, plugins, and customizations. WordPress.com is a hosted service with limited free plan, automatic updates, and restrictions on plugins and monetisation unless you pay for higher tiers.

What is the WordPress loop?
Answer: The WordPress loop is the PHP code that retrieves posts from the database and displays them. It uses have_posts() and the_post() to iterate through posts within the main query, generating the content for archive pages, single posts, and custom post types. Developers can customize loops with WP_Query or pre_get_posts.

What are hooks in WordPress? Describe actions and filters.
Answer: Hooks allow developers to modify or extend WordPress behavior without editing core files. Actions (do_action) let you add or remove functionality at specific points. Filters (apply_filters) modify data before it is displayed or saved. Use add_action() and add_filter() to attach custom functions.

Explain the WordPress database schema. Name important tables.
Answer: Key tables: wp_posts (content, post titles, meta), wp_postmeta (post metadata), wp_users (user accounts), wp_usermeta (user metadata), wp_terms (taxonomies), wp_term_taxonomy (taxonomy type), wp_term_relationships (term to post links), wp_comments, wp_options (settings). Prefix (wp_) can be changed for security.

What is a child theme and why would you use one?
Answer: A child theme inherits functionality and styling from a parent theme. It allows you to modify or extend the parent theme without losing changes when the parent is updated. It contains style.css and functions.php; it overrides parent templates by copying them into the child theme.

What files are required for a WordPress theme?
Answer: Minimum: style.css (with header comment), index.php. Common files: functions.php, header.php, footer.php, sidebar.php, single.php, page.php, archive.php, author.php, search.php, 404.php. For blocks, theme.json is required for full site editing.

What is functions.php and what can you do with it?
Answer: functions.php is a theme file where you add custom PHP code to modify theme functionality. You can enqueue scripts/styles, add theme support features (post thumbnails, menus, widgets), define custom functions, and attach hooks.

What is the difference between get_header() and wp_head()?
Answer: get_header() includes the header.php template file. wp_head() is an action hook that fires in the <head> section; plugins and themes use it to output scripts, styles, and meta tags. It is called inside header.php.

What are shortcodes? How do you create one?
Answer: Shortcodes are macros (e.g., ) that insert dynamic content into posts/pages. Create using add_shortcode('tag', 'callback'). The callback function returns the output string. Example: function my_shortcode() { return "Hello"; } add_shortcode('hello', 'my_shortcode');.

What are custom post types? Give an example.
Answer: Custom post types extend WordPress beyond posts and pages to store different content types (e.g., Products, Portfolio, Events). Register using register_post_type() in functions.php or a plugin. They can have their own taxonomies, templates, and admin UI.

What is the difference between posts and pages?
Answer: Posts are blog entries, listed in reverse chronological order, have categories and tags, and are shown on the blog page. Pages are hierarchical, static, not time‑based, and do not use categories or tags. Pages are used for “About” and “Contact”.

How do you enqueue scripts and styles correctly in WordPress?
Answer: Use wp_enqueue_script() and wp_enqueue_style() inside a function hooked to wp_enqueue_scripts. This ensures dependencies are loaded properly, handles versioning, and prevents conflicts. Never hardcode <script> or <link> tags.

What is the wp_localize_script function used for?
Answer: It passes PHP variables to JavaScript. You provide an array of data that becomes a JavaScript object in the global scope. Useful for AJAX URL, nonces, translations, or any dynamic data needed by scripts.

How does WordPress handle routing (URL rewriting)?
Answer: WordPress uses mod_rewrite (Apache) or similar to parse URLs. The index.php file acts as a front controller, and the rewrite rules direct requests to the appropriate handler based on the requested URL. Rules are stored in .htaccess (or web.config) and generated via the Settings > Permalinks page.

What is the function the_permalink() vs get_permalink()?
Answer: the_permalink() echoes the permalink (URL) of the current post within the loop. get_permalink() returns the permalink as a string, optionally for a specific post ID.

What is a WordPress transient?
Answer: Transients store temporary, cacheable data with an expiration time. They use the options table (or object cache like Redis). Use set_transient()get_transient()delete_transient(). Useful for caching API responses, complex queries, or expensive computations.

How do you create a custom database table in WordPress?
Answer: Use $wpdb->query() with CREATE TABLE inside register_activation_hook. Always check $wpdb->prefix for table prefix. For updates, use dbDelta() to handle schema changes. Also increment the plugin version and run upgrade routines.

What is the WP_Query class?
Answer: WP_Query is a powerful class for custom database queries for posts. It allows you to specify parameters (post type, category, meta key, order) and loop through results without affecting the main query. Use new WP_Query($args) and then while($query->have_posts()).

How do you modify the main query before it runs?
Answer: Use pre_get_posts action hook. Inside the callback, check !is_admin() and $query->is_main_query(). Then modify query parameters like set('posts_per_page', 10). Do not run query_posts() directly; use pre_get_posts.

What is the difference between home_url() and site_url()?
Answer: site_url() returns the WordPress installation URL (where core files are). home_url() returns the address set for the front page (Site Address). They are often the same, but can differ when WordPress is installed in a subdirectory.

How do you add a custom menu location?
Answer: In functions.php, use register_nav_menus() with an array of location slugs and descriptions. Then in theme templates, call wp_nav_menu(array('theme_location'=>'slug')).

What is the role of wp-config.php file?
Answer: wp-config.php contains WordPress configuration settings: database connection details, table prefix, authentication keys, debug mode, memory limit, and custom constants. It is not part of the core distribution and must be created during installation.

What are the best security practices for WordPress?
Answer: Keep core, themes, and plugins updated. Use strong passwords and two‑factor authentication. Disable file editing via define('DISALLOW_FILE_EDIT', true). Limit login attempts. Use security plugins (Wordfence, Sucuri). Change default wp_ table prefix. Use SSH/SFTP instead of FTP. Regularly backup.

What is a WordPress cron? How is it different from system cron?
Answer: WP‑Cron is a pseudo‑cron system that runs when a page is loaded (not as a separate daemon). Scheduled tasks (publishing future posts, checking updates) are triggered on visitor requests. It is less reliable than system cron for critical tasks; you can disable it and set up a real cron job.

How do you improve WordPress performance?
Answer: Use caching plugins (WP Rocket, W3 Total Cache), enable page caching, browser caching, and object caching (Redis/Memcached). Optimise images, minify CSS/JS, use a CDN, reduce external HTTP requests, optimise database (clean revisions, transients), use a lightweight theme, and upgrade PHP version.

What is the REST API in WordPress?
Answer: The WordPress REST API provides JSON‑based endpoints for interacting with WordPress data (posts, users, comments, custom post types) remotely. It is used by Gutenberg blocks, mobile apps, and headless WordPress setups (frontend separated from backend). Authenticated with nonces or OAuth.

What are meta boxes? How do you add one?
Answer: Meta boxes are draggable boxes on the post/page edit screen for adding custom fields. Add with add_meta_box(), hooked to add_meta_boxes. Render the HTML inside a callback function. Save metadata using save_post action.

What is the difference between do_shortcode() and apply_shortcodes()?
Answer: Both process shortcodes in a string. do_shortcode() is the original alias; apply_shortcodes() was introduced later. They are identical. Use them when you need to parse shortcodes manually in custom content.

What is wp_nonce_field() and why is it used?
Answer: It outputs a nonce field for security. Nonces (number used once) verify that the request originates from the current site/user, preventing CSRF attacks. Often used in forms, AJAX, and admin actions. Verify with check_admin_referer() or wp_verify_nonce().

How do you create a custom taxonomy?
Answer: Use register_taxonomy() in functions.php or a plugin. Provide taxonomy name, object type (post, page, custom post type), and arguments (labels, hierarchical (like categories) or non‑hierarchical (like tags)). Flush rewrite rules after registration.

What is the difference between the_content() and get_the_content()?
Answer: the_content() displays the formatted post content (with filters applied). get_the_content() returns the raw content as a string, which you can manipulate before output. Both are used inside the loop.

How do you override a parent theme’s function?
Answer: In a child theme, you cannot directly override a function defined in the parent. Instead, the parent theme should provide a pluggable function using if ( ! function_exists() ). Then the child can declare the same function name and it will replace the parent’s.

What is the purpose of wp_reset_query() and wp_reset_postdata()?
Answer: wp_reset_query() restores the original main query after using query_posts() (which is discouraged). wp_reset_postdata() restores global post data after a custom WP_Query loop to avoid affecting other loops. Always call after custom loops.

What are widgets in WordPress?
Answer: Widgets are small blocks that can be placed in widget areas (sidebars, footers). They provide dynamic content (categories, recent posts, search, custom HTML). Register widget areas with register_sidebar(). Use the Widgets screen or Customizer.

What is the role of WP_User_Query?
Answer: WP_User_Query is used to retrieve users from the database with various parameters (role, meta key, order). Similar to WP_Query, it returns an array of user objects. Useful for building custom user lists.

What are admin notices and how do you display them?
Answer: Admin notices are feedback messages shown in the WordPress admin area (success, error, warning). Use add_action('admin_notices', 'callback') and echo HTML with classes notice notice-success. Also built‑in functions like settings_errors().

Explain the difference between include and require in PHP context of WordPress.
Answer: include produces a warning if the file is missing; script continues. require produces a fatal error and stops execution. In WordPress, you typically use get_template_part() or locate_template() for template inclusion.

What is a WordPress theme template hierarchy?
Answer: The template hierarchy decides which template file is used for a given request. For a single post: first single-posttype.php, then single.php, then index.php. For pages: custom template > page-{slug}.php > page-{id}.php > page.php > index.php.

What is the function register_activation_hook?
Answer: It registers a callback that runs when a plugin is activated. Used to set default options, create database tables, or flush rewrite rules. Corresponding hooks: register_deactivation_hookregister_uninstall_hook.

How do you handle AJAX in WordPress?
Answer: For front‑end AJAX, use admin-ajax.php with actions. Add hooks: wp_ajax_myaction (for logged‑in) and wp_ajax_nopriv_myaction (for logged‑out). In JavaScript, pass action parameter. Also use REST API endpoints for modern development.

What are the advantages of using WP_List_Table class?
Answer: WP_List_Table helps create admin tables with sorting, pagination, bulk actions, and search. It is used internally for posts, pages, comments, users. You can extend it to display custom data in admin.

What is the difference between sanitize_text_field() and esc_html()?
Answer: sanitize_text_field() removes invalid UTF‑8, strips tags, and removes extra whitespace; used for cleaning input before saving to database. esc_html() escapes HTML entities for safe output to prevent XSS. Security principle: sanitize on input, escape on output.

What is a WordPress multisite network?
Answer: Multisite allows running multiple virtual sites from a single WordPress installation. Each site can have its own themes, plugins, and users. Enabled by adding define('WP_ALLOW_MULTISITE', true) in wp‑config.php. Super admin manages the network.

What is the wp_remote_get() function?
Answer: It performs HTTP GET requests safely within WordPress. It handles timeouts, redirects, and includes error checking. Returns a WP_Error on failure or an array with response headers and body. Prefer over file_get_contents() for external URLs.

What are the common caching types in WordPress?
Answer: Page caching (static HTML), object caching (database query results), opcode caching (PHP scripts), and CDN (assets). Implement with plugins (W3 Total Cache) or server‑side (Varnish, Redis).

What is the difference between get_posts() and WP_Query?
Answer: get_posts() uses WP_Query internally but returns an array of post objects without preserving global state. WP_Query gives more control (like pagination, custom loop counters). Both are valid; get_posts() is simpler for small lists.

How do you add custom image sizes?
Answer: add_image_size('name', width, height, crop) in functions.php. Then use the_post_thumbnail('name') in templates. Regenerate thumbnails after adding new sizes with a plugin or WP CLI.

What is the purpose of register_rest_route()?
Answer: It adds custom REST API endpoints. Define namespace, route, HTTP methods, and callback. Return WP_REST_Response or array. Authentication can be handled with permission_callback.

What is the role of wp_schedule_event()?
Answer: It schedules a recurring cron job. Parameters: timestamp, recurrence (hourly, twicedaily, daily), hook name. The hook must have an action handler. Use wp_clear_scheduled_hook() to unschedule.

How do you internationalize a WordPress theme/plugin?
Answer: Use text domain and functions like __()_e()_x()esc_html__(). Include .pot file generation with tools like Poedit. Load the text domain with load_theme_textdomain() or load_plugin_textdomain(). This allows translation into different languages.

What is the difference between get_template_directory_uri() and get_stylesheet_uri()?
Answer: get_template_directory_uri() returns the parent theme directory URL. get_stylesheet_uri() returns the child theme (or active theme) stylesheet URL. In a child theme, use get_template_directory_uri() for parent assets, get_stylesheet_uri() for child.

How do you debug a “white screen of death” in WordPress?
Answer: Enable WP_DEBUG and WP_DEBUG_LOG in wp‑config.php to view errors in /wp‑content/debug.log. Also check server error logs, deactivate all plugins, switch to default theme, increase memory limit, and check .htaccess.

What is wp_die() function?
Answer: wp_die() terminates script execution and displays an error message. It is used for error handling in AJAX (wp_send_json_error() internally) and for fatal errors. It replaces PHP’s die() with WordPress styling and hooks.

What is the purpose of wp_mail()?
Answer: wp_mail() sends emails using the WordPress mail system (PHPMailer). It allows filtering via wp_mail_from and wp_mail_content_type. Use it for contact forms, notifications, and password resets.

How do you customize the login page logo?
Answer: Use login_headertitle and login_headerurl filters. Custom CSS can be added with login_enqueue_scripts. For example: add_filter('login_headerurl', function() { return home_url(); });.

What is a custom walker class in WordPress?
Answer: A custom walker extends Walker_Nav_Menu (or other Walker classes) to modify how menu items are rendered. It allows you to add custom HTML attributes, icons, or extra elements.

What is the role of the $wpdb global object?
Answer: $wpdb is the global database access object. It provides methods: get_results()insert()update()delete()prepare() for safe SQL queries. It also holds tables like $wpdb->posts. Use it for custom database operations.

How do you prevent direct access to PHP files in themes/plugins?
Answer: Add at the top of each file: defined('ABSPATH') or die('No direct access');. This prevents someone from executing the file directly via URL.

What are the required fields for a plugin activation?
Answer: A plugin needs a main PHP file with a plugin header comment (Plugin Name, Description, Version, Author). No minimum code; the header makes it visible in the admin.

What is the difference between a site and a page in WordPress Multisite?
Answer: In Multisite, a “site” is a separate website with its own content, users, and options. A “page” is a single piece of content (post type) within a site. Each site can have many pages.

What are the major hooks in plugin activation process?
Answer: register_activation_hook()register_deactivation_hook()register_uninstall_hook(). Also activate_plugin action before activation, activated_plugin after activation.

How do you modify the WordPress search to include custom fields?
Answer: Use pre_get_posts action and posts_join and posts_where filters to add meta queries. Or use WP_Query directly with meta_query parameter. For advanced search, use SearchWP or Relevanssi plugins.

What is the wp_cache_* family of functions?
Answer: wp_cache_set()wp_cache_get()wp_cache_delete() are used for object caching. They store key‑value pairs in memory (if persistent cache is configured). Faster than transients for transient data.

How do you handle file uploads in WordPress securely?
Answer: Use wp_handle_upload() which validates mime types, sizes, and moves the file. Use wp_check_filetype() and current_user_can('upload_files'). Also filter allowed mime types with upload_mimes.

What is the purpose of wp_set_current_user()?
Answer: It sets the current user for the duration of the request, useful in AJAX or REST authentication. It updates the global $current_user object.

Explain the WP_Screen class.
Answer: WP_Screen provides information about the current admin screen (post type, taxonomy, ID, action). Used in hooks like load-{$hook_suffix} to conditionally add admin assets or help tabs.

What is the redirect_canonical() function?
Answer: It prevents duplicate content by redirecting to the canonical URL for a request (e.g., removing query parameters, adding trailing slash). It is called by default but can be disabled with remove_filter('template_redirect', 'redirect_canonical').

How do you create a dashboard widget?
Answer: Use wp_add_dashboard_widget() hooked to wp_dashboard_setup. Provide widget ID, name, callback function. The callback outputs HTML.

What is the difference between get_queried_object() and global $post?
Answer: get_queried_object() returns the current query object (post, term, user) depending on the main query. global $post is the current post object within the loop. On single post pages, both refer to the same post.

What are the init and wp_loaded action hooks?
Answer: init runs after WordPress has finished loading but before headers are sent. Used for registering post types, taxonomies, shortcodes. wp_loaded runs after the main query is set up but before headers sent.

How do you implement breadcrumbs in WordPress without a plugin?
Answer: Write a custom function that uses get_the_terms()wp_get_post_terms(), and get_post_ancestors(). For home, add link; for single, get categories/parent pages; loop and output links.

What is wp_add_inline_style() used for?
Answer: It allows injecting dynamic CSS directly after an enqueued stylesheet or before other styles. Useful for customizer settings or dynamic theme options without creating separate files.

What are the different roles and capabilities in WordPress?
Answer: Default roles: Super Admin (multisite), Administrator, Editor, Author, Contributor, Subscriber. Capabilities are specific permissions (edit_posts, publish_pages, etc.). Use add_role()remove_cap()add_cap().

What is wp_verify_nonce() and how does it work?
Answer: It verifies that the nonce token matches the current user session and action. It returns false if invalid, expires, or tampered. Used to protect forms and AJAX requests from CSRF.

How do you optimise database in WordPress?
Answer: Use WP_Optimize plugin or manual queries: DELETE FROM wp_postmeta WHERE meta_key = '_edit_lock'; optimize tables; delete post revisions: DELETE FROM wp_posts WHERE post_type = 'revision'; delete spam comments.

What is the purpose of wp_parse_args()?
Answer: It merges user‑defined arguments with default arguments (array). Used to handle function parameters gracefully, similar to wp_parse_args($args, $defaults).

How do you set up a WordPress cron job using a real system cron?
Answer: Disable WP‑Cron in wp‑config.php: define('DISABLE_WP_CRON', true). Set up a system cron job to call wget -q -O - https://example.com/wp-cron.php?doing_wp_cron every 5 minutes.

What is the difference between the_excerpt() and get_the_excerpt()?
Answer: the_excerpt() displays the excerpt; get_the_excerpt() returns it. You can filter excerpt length with excerpt_length and excerpt more text with excerpt_more.

How do you add custom rewrite rules?
Answer: Use add_rewrite_rule() in init action, then flush rewrite rules (flush_rewrite_rules()). Example: add_rewrite_rule('^product/([^/]*)/?','index.php?post_type=product&name=$matches[1]','top').

What is the purpose of wp_get_attachment_url()?
Answer: It returns the URL of an attachment (image, file) given its attachment ID. Used in media handling.

How would you disable the Gutenberg editor for a specific post type?
Answer: Use add_filter('use_block_editor_for_post_type', '__return_false') for that post type. Alternatively, remove_post_type_support('page', 'editor') (but that removes all editors).

What is the WP_Error class?
Answer: WP_Error is used to store and manage errors (such as in REST API responses, file uploads, user authentication). Methods: add()get_error_messages()is_error().

How do you implement a redirect after login?
Answer: Use login_redirect filter: add_filter('login_redirect', function($redirect_to, $request, $user){ ... }, 10, 3). Based on user role or custom logic.

What is the pre_get_posts action commonly used for?
Answer: To modify the main query before execution, e.g., exclude certain categories from the blog page, change posts per page on archive pages, or alter custom post type queries.

What is the purpose of wp_extract_urls()?
Answer: It extracts all URLs from a piece of content (string). Useful for scraping links from post content.

How do you implement a custom password reset flow?
Answer: Use lostpassword_post filter to validate, retrieve_password() to generate reset key, wp_mail() to send custom email, and password_reset action to change password.

What is the oEmbed feature in WordPress?
Answer: WordPress automatically converts URLs from supported services (YouTube, Twitter) into embedded players when pasted into the editor. Works via oEmbed standard.

How do you add a custom bulk action in admin posts list?
Answer: Use bulk_actions-edit-post filter to add actions. Then handle the action using handle_bulk_actions-edit-post filter. For custom UI, also use jQuery modifications.

What are the differences between WP_Date_QueryWP_Meta_Query, and WP_Tax_Query?
Answer: WP_Date_Query adds date‑based conditions to WP_Query. WP_Meta_Query filters by post meta. WP_Tax_Query filters by taxonomy terms. They are used inside the tax_querymeta_query, and date_query arguments.

What is the function wp_salt()?
Answer: It returns salts (cryptographic keys) defined in wp‑config.php (AUTH_KEY, SECURE_AUTH_KEY, etc.). Used for hashing passwords and cookies.

How do you handle version control for WordPress development?
Answer: Use .gitignore to exclude wp‑config.php, /wp‑content/uploads/, /wp‑content/cache/, debug logs. Track themes, plugins, and custom code. Use WP CLI for database migrations.

What is WP_Filesystem and why is it needed?
Answer: WP_Filesystem provides an abstraction layer for file operations, allowing the system to use FTP or direct file access depending on server configuration. Required for safe file writes in plugins (e.g., theme/plugin update, file creation).

How do you clone the current post and save it as a new draft?
Answer: Use get_post() to fetch post object, unset ID and dates, then wp_insert_post() with post_status = 'draft'. Also copy post meta and taxonomies.

What is the RYAN constant?
Answer: Not standard. Probably a trick question. The correct answer: there is no constant RYAN; might refer to WP_DEBUG_DISPLAY or others. Be aware.

What is the wp_filter_content_tags function?
Answer: It adds loading="lazy" attributes to img tags in content. Introduced in WordPress 5.5. Called automatically via the_content filter.

Why should we hire you as a WordPress developer?
Answer: I have extensive experience with WordPress core, theme and plugin development, and customizations using hooks and filters. I follow coding standards, prioritize security and performance, and can integrate third‑party APIs. I debug efficiently using WP_DEBUG and Xdebug. I also maintain scalable codebases and work with version control (Git) and deployment pipelines. I am up‑to‑date with Gutenberg block development and the REST API.

Conclusion

You’ve reached the final question, and you can already feel it — that electric, impatient eagerness to step into the interview and finally show them everything you’ve got. Themes, plugins, hooks, custom post types, the WordPress loop, security best practices — it’s all locked and loaded in your mind, and you’re itching to demonstrate that you’re not just a user of WordPress, but a true builder who understands what happens under the hood.

This isn’t a nervous, fidgety energy. It’s the thrilling kind — the kind that comes from knowing you’ve done your homework, you’ve practiced the tough questions, and you’re carrying a toolkit of answers that are clear, practical, and genuine. You’re ready to talk about the WordPress REST API with the same ease as optimizing a slow site, and that wide-ranging confidence is making you genuinely excited for the conversation ahead.

So go ahead — schedule that interview, walk in with bright eyes, and let your eager, passionate WordPress knowledge pour out. You’re not hoping you’ll pass; you’re ready to own it. The WordPress world is huge, and it’s waiting for developers like you. Go make your mark!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top