WordPress Interview Questions & Answers
Here, you will find Top WordPress Interview Questions and Answers.
These WordPress interview questions are helpful for freshers (beginners) as well as experienced job seekers.
Find, WordPress interview questions are related to WordPress CMS, functions, admin panel, file structure, database, themes, plugins, actions, filters along with examples.
What is WordPress?
WordPress is a free and open source Content Management System (CMS). It lets you create and manage a website without writing all the code yourself. You add content from a dashboard, choose a design with a theme, and add features with plugins.
It is written in PHP and uses a MySQL or MariaDB database. WordPress started in 2003 as a blogging tool, and today it runs around 4 out of 10 websites on the internet: blogs, business sites, news portals, online shops (with WooCommerce) and even web applications.
You can see the version of your own site with one command:
$ wp core version
7.1.4
Read more in WordPress Introduction.
In what year did WordPress come out?
WordPress came out in 2003. The first version (0.7) was released on 27 May 2003. It was started by Matt Mullenweg and Mike Little as a fork of an older blogging tool called b2/cafelog.
It began as a simple blog system. Over the years it got pages, plugins, themes, custom post types, the REST API and the block editor, and became a full CMS. Today it is maintained by a big community of volunteers.
Version 7.0 was released in May 2026. See What is new in WordPress 7.0?
How many default tables are in a WordPress database?
A fresh WordPress install creates 12 tables in the database:
$ wp db tables
wp_commentmeta
wp_comments
wp_links
wp_options
wp_postmeta
wp_posts
wp_term_relationships
wp_term_taxonomy
wp_termmeta
wp_terms
wp_usermeta
wp_users
The main ones are wp_posts (posts, pages and other content), wp_postmeta (custom fields), wp_options (settings), wp_users and wp_usermeta, wp_comments and the term tables wp_terms, wp_term_taxonomy and wp_term_relationships. Plugins can add more tables. Read WordPress Database.
Where is the WordPress content stored?
WordPress saves its content in two places:
- The database (MySQL or MariaDB): posts and pages (
wp_posts), custom fields, comments, users, categories and tags, and all settings (wp_options). - The file system: uploaded images and files in
wp-content/uploads, and the code of themes and plugins inwp-content/themesandwp-content/plugins.
So a full backup needs both the database and the wp-content folder. See Backup and Update.
What is the default table prefix for the WordPress database?
The default prefix is wp_, so the tables are named wp_posts, wp_options and so on. It is set in wp-config.php:
$ wp config get table_prefix
wp_
$ wp db prefix
wp_
You can choose another prefix when you install the site (like site1_), which also lets many sites share one database. In code, never write the prefix by hand, use $wpdb->prefix or $wpdb->posts.
What are the popular plugins in WordPress for SEO?
The most used SEO plugins in the WordPress.org directory are:
| Plugin | Active installs (rounded) |
|---|---|
| Yoast SEO | 10+ million |
| Rank Math SEO | 4+ million |
| All in One SEO | 2+ million |
They help with SEO title, meta description, sitemaps, canonical URLs, schema and content hints. Use only one of them. See WordPress SEO with Yoast and the full plugin list.
What is a WordPress theme?
A WordPress theme is a group of files (templates, stylesheets, images and sometimes JavaScript) that decide how your website looks. When you switch the theme, your posts and pages stay the same, but the design and layout change.
There are two kinds: classic themes with PHP templates (like single.php) and block themes with HTML templates and a theme.json file, which you edit in the Site Editor.
Themes are saved in wp-content/themes:
$ wp theme list –fields=name,status
name status
twentytwentyfive active
twentytwentyfour inactive
twentytwentythree inactive
Learn more in WordPress Themes.
What are commonly used WordPress theme functions?
| Function | Use |
|---|---|
| get_header(), get_footer(), get_sidebar() | Load header.php, footer.php, sidebar.php |
| wp_head(), wp_footer() | Hooks for scripts, styles and plugins. Needed in every theme |
| bloginfo( ‘name’ ) | Prints site details |
| home_url(), site_url() | Site addresses |
| the_title(), the_content(), the_excerpt() | Post details in the loop |
| the_permalink(), the_post_thumbnail() | Post link and featured image |
| wp_nav_menu() | Print a menu |
| dynamic_sidebar() | Print a widget area |
| get_template_part() | Load a reusable file |
| get_template_directory_uri() | URL of the theme folder |
Tags that start with the_ print, while get_the_ versions return the value. See Theme Files and Functions.
Describe WordPress files and directory structure
The root folder of a WordPress site contains:
| Item | Purpose |
|---|---|
| wp-admin | Dashboard code. Never edit |
| wp-includes | Core libraries. Never edit |
| wp-content | Your themes, plugins and uploads |
| wp-config.php | Database and main settings |
| index.php, wp-load.php, wp-settings.php | Start WordPress |
| wp-login.php | Login page |
| .htaccess | Rewrite rules (Apache) |
$ ls wp-content
index.php
mu-plugins
plugins
themes
uploads
More in WordPress Files and Folder Structure.
How to limit WordPress post content length?
Use wp_trim_words() to cut a text to a number of words, and the excerpt_length filter to change the length of automatic excerpts.
$content = 'WordPress is a free and open source CMS. It runs a large part of the web and has thousands of themes and plugins for every kind of site.';
echo wp_trim_words( $content, 10, '...' ) . "\n";
echo wp_html_excerpt( $content, 40, '...' ) . "\n";
echo mb_strimwidth( $content, 0, 40, '...' );
WordPress is a free and open source CMS. It runs…
WordPress is a free and open source CMS….
WordPress is a free and open source C…
wp_trim_words( $text, $num_words, $more ): counts words, and removes the HTML tags.wp_html_excerpt( $str, $count, $more ): counts characters, and removes the HTML tags.
To change the length of the automatic excerpt (used by the_excerpt()), add a filter in functions.php:
add_filter( 'excerpt_length', function () {
return 20; // words
}, 999 );
add_filter( 'excerpt_more', function () {
return '...';
} );
Inside the loop you can use it with the content: echo wp_trim_words( get_the_content(), 30 );. The default excerpt is 55 words.
Which function is used to get the home URL in WordPress?
Use home_url(). It gives the address of the front of your site, and you can add a path to it:
$ wp eval 'echo home_url() . "\n" . home_url( "/contact/" ) . "\n" . site_url() . "\n" . get_bloginfo( "url" );'
http://example.com
http://example.com/contact/
http://example.com
http://example.com
home_url(): the address where visitors open the site.site_url(): the address where the WordPress core files are installed. It is different fromhome_url()only when WordPress is in a sub folder.get_bloginfo( 'url' ): same ashome_url().
Always use esc_url( home_url( '/' ) ) when you print it in HTML.
Which are the necessary files for a WordPress theme?
A classic theme must have two files:
style.csswith a header comment (at leastTheme Name).index.php, the fallback template.
Usually a theme also has header.php, footer.php, functions.php, single.php, page.php and screenshot.png. A block theme needs style.css and templates/index.html.
/*
Theme Name: Mini Theme
*/
<?php echo 'Hello from a two file theme';
$ wp theme activate tc-mini
Success: Switched to 'Mini Theme' theme.
$ curl -s http://example.com/
Hello from a two file theme
What is the WordPress default feed cache recreation time? How to change it?
When WordPress reads a remote feed with fetch_feed() (for example in the dashboard news widget), it saves the result in a transient so it does not ask the other site every time. The default cache time is 12 hours, which is 43200 seconds.
Change it with the wp_feed_cache_transient_lifetime filter. The filter gets the time in seconds, and the feed URL:
$default = apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, 'https://example.com/feed/' );
echo "Default: $default seconds\n";
add_filter( 'wp_feed_cache_transient_lifetime', function ( $seconds, $url ) {
return 30 * MINUTE_IN_SECONDS; // cache for 30 minutes
}, 10, 2 );
$new = apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, 'https://example.com/feed/' );
echo "After the filter: $new seconds";
Default: 43200 seconds
After the filter: 1800 seconds
A shorter time shows new feed items faster, but uses more requests to the remote server. This is not the same as the feed of your own site, which is made fresh on every request.
How to create a WordPress global options page?
Use the Settings API: add_options_page() for the page, register_setting() for the option, and add_settings_field() for the fields. This is the shortest complete example:
add_action( 'admin_menu', function () {
add_options_page( 'My Options', 'My Options', 'manage_options', 'my-options', 'my_options_page' );
} );
add_action( 'admin_init', function () {
register_setting( 'my_group', 'my_company', array( 'sanitize_callback' => 'sanitize_text_field' ) );
add_settings_section( 'my_section', 'Company', '__return_false', 'my-options' );
add_settings_field( 'my_company', 'Company name', function () {
echo '<input type="text" name="my_company" value="' . esc_attr( get_option( 'my_company' ) ) . '">';
}, 'my-options', 'my_section' );
} );
function my_options_page() { ?>
<div class="wrap">
<h1>My Options</h1>
<form action="options.php" method="post">
<?php settings_fields( 'my_group' ); do_settings_sections( 'my-options' ); submit_button(); ?>
</form>
</div>
<?php }
Read the value anywhere with get_option( 'my_company' ). The sanitize callback cleans the value when it is saved:
register_setting( 'my_group', 'my_company', array( 'sanitize_callback' => 'sanitize_text_field' ) );
update_option( 'my_company', '<b>Acme</b> <script>x()</script>Ltd' );
echo get_option( 'my_company' );
Acme Ltd
Full steps with a tested plugin: WordPress Plugin Settings Page.
How to create a WordPress plugin from scratch?
Four steps:
- Make a folder in
wp-content/plugins, likemy-plugin. - Add a PHP file with the same name. Write the header comment with at least
Plugin Name. - Write your code with hooks (actions and filters), a unique prefix and an
ABSPATHcheck. - Activate it from the Plugins screen (or
wp plugin activate my-plugin).
<?php
/**
* Plugin Name: TC Hello Plugin
* Description: Adds a small text in the footer.
* Version: 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
add_action( 'wp_footer', function () {
echo '<p class="tchp">Made with WordPress</p>';
} );
$ wp plugin activate tc-hello-plugin
Plugin 'tc-hello-plugin' activated.
Success: Activated 1 of 1 plugins.
$ curl -s http://example.com/ | grep -o '<p class="tchp">[^<]*</p>'
<p class="tchp">Made with WordPress</p>
A full tested example with activation and uninstall is in Create a WordPress Plugin.
How to increase maximum execution time in PHP and WordPress?
A long job (an import, a big backup or a slow plugin) can stop with Maximum execution time exceeded. The limit is set by the PHP setting max_execution_time (in seconds). Ways to raise it:
- php.ini:
max_execution_time = 300 - .htaccess (Apache with mod_php):
php_value max_execution_time 300 - In code: call
set_time_limit( 300 );orini_set( 'max_execution_time', '300' );before the long job. - Your host panel: many hosts have a PHP settings page.
Here we check the value on a real page, before and after calling set_time_limit() from a small must use plugin:
<?php
add_action( 'wp_footer', function () {
echo '<!-- before: ' . ini_get( 'max_execution_time' ) . ' -->';
set_time_limit( 300 );
echo '<!-- after: ' . ini_get( 'max_execution_time' ) . ' -->';
} );
$ curl -s http://example.com/ | grep -o "<!– \(before\|after\): [0-9]* –>"
<!– before: 30 –>
<!– after: 300 –>
WP-CLI scripts have no time limit by default, which is why long jobs are often done with it. Some hosts block set_time_limit(), and a web server (Nginx or a proxy) can have its own timeout too. Do not set it too high on a live site.
What menu positions and order are available in WordPress?
When you add a top level menu with add_menu_page(), the last parameter is the position. A lower number shows higher in the menu. The default positions are:
| Position | Menu item |
|---|---|
| 2 | Dashboard |
| 4 | Separator |
| 5 | Posts |
| 10 | Media |
| 15 | Links (hidden on new sites) |
| 20 | Pages |
| 25 | Comments |
| 59 | Separator |
| 60 | Appearance |
| 65 | Plugins |
| 70 | Users (or Profile) |
| 75 | Tools |
| 80 | Settings |
| 99 | Separator |
You can see them in the WordPress source file wp-admin/menu.php:
$ grep -n "^\$menu\[" wp-admin/menu.php | cut -c1-60
29:$menu[2] = array( __( 'Dashboard' ), 'read', 'index.php',
69:$menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-
73:$menu[10] = array( __( 'Media' ), 'upload_files', 'upload
89:$menu[15] = array( __( 'Links' ), 'manage_links', 'link-m
205:$menu[59] = array( '', 'read', 'separator2', '', 'wp-men
209:$menu[60] = array( __( 'Appearance' ), $appearance_capab
323:$menu[65] = array( sprintf( __( 'Plugins %s' ), $count )
390:$menu[75] = array( __( 'Tools' ), 'e
405:$menu[80] = array( __( 'Se
417:$menu[99] = array( '', 'read', 'separator-last', '', 'wp
add_action( 'admin_menu', function () {
add_menu_page( 'Reports', 'Reports', 'manage_options', 'my-reports', 'my_reports_page', 'dashicons-chart-bar', 26 );
} );
With position 26, the menu shows after Comments (25). Do not use the same number as another item: pick a decimal like 26.5 (as a string) to avoid an overwrite.
What is the difference between Posts & Pages in WordPress?
Posts are for blog or news content. They are shown newest first, can have categories and tags, appear in the RSS feed and usually allow comments.
Pages are for static content that does not change with time, like About us, Contact or Privacy Policy. They have no categories or tags, are not in the feed, can have a parent page (hierarchy), and can use page templates.
| Point | Posts | Pages |
|---|---|---|
| Order | By date | By menu or page order |
| Categories and tags | Yes | No |
| Hierarchy | No | Yes |
| In RSS feed | Yes | No |
Both are saved in the same wp_posts table, with a different post_type (post or page). See Posts and Pages.
What are the different user roles in WordPress?
A role is a named group of permissions (called capabilities). WordPress has five default roles:
| Role | What the user can do |
|---|---|
| Administrator | Everything on the site |
| Editor | Publish and manage all posts and pages, and comments |
| Author | Write, publish and manage only his own posts |
| Contributor | Write his own posts, but cannot publish them |
| Subscriber | Only manage his profile |
$ wp role list –fields=role,name
role name
administrator Administrator
editor Editor
author Author
contributor Contributor
subscriber Subscriber
On a multisite network there is also the Super Admin role. Read more in Users and Roles.
Which Gutenberg blocks support wide and full width alignment?
Wide and full width alignment make a block go outside the normal content width. A block supports it through its supports.align setting. We can ask the block registry of WordPress 7.1 for the real list:
$wide_full = array();
foreach ( WP_Block_Type_Registry::get_instance()->get_all_registered() as $name => $block ) {
$align = $block->supports['align'] ?? null;
if ( $align === true ) {
$wide_full[] = $name; // true means all alignments
} elseif ( is_array( $align ) && in_array( 'wide', $align, true ) && in_array( 'full', $align, true ) ) {
$wide_full[] = $name;
}
}
sort( $wide_full );
echo count( $wide_full ) . " blocks support both wide and full:\n" . wordwrap( implode( ', ', $wide_full ), 90, "\n" );
53 blocks support both wide and full:
core/accordion, core/archives, core/audio, core/avatar, core/breadcrumbs, core/buttons,
core/calendar, core/categories, core/columns, core/comment-template, core/comments,
core/comments-pagination, core/comments-title, core/cover, core/details, core/embed,
core/file, core/gallery, core/group, core/heading, core/image, core/latest-comments,
core/latest-posts, core/media-text, core/navigation, core/paragraph, core/playlist,
core/post-comments, core/post-content, core/post-featured-image, core/post-template,
core/post-title, core/pullquote, core/query, core/query-no-results, core/query-pagination,
core/query-title, core/query-total, core/quote, core/rss, core/separator, core/site-logo,
core/site-tagline, core/site-title, core/table, core/tabs, core/tag-cloud,
core/template-part, core/term-description, core/term-name, core/term-template,
core/terms-query, core/video
The list includes Image, Gallery, Cover, Group, Columns, Heading, Paragraph, Table, Video, Quote, Query Loop and the Navigation block. The list changes in new versions of WordPress, so use the code above to see the list of your own site.
The theme must allow it
For a block theme wide and full alignment are on by default. A classic theme must turn it on:
add_theme_support( 'align-wide' );
The width of the “wide” area comes from layout.wideSize in theme.json. See Block Themes and theme.json.