Top Intermediate/Advanced WordPress interview questions

1. What are custom post types?

Custom Post Types (CPTs) allow creating custom content types beyond default posts and pages (e.g., Products, Testimonials).

2. How can you create a custom post type in WordPress?

Using register_post_type() in functions.php:

function custom_post_type() {
register_post_type('books', [
'public' => true,
'label' => 'Books',
'supports' => ['title', 'editor', 'thumbnail'],
]);
}
add_action('init', 'custom_post_type');


3. How do you create a custom taxonomy in WordPress?

Using register_taxonomy():

function create_book_taxonomy() {
register_taxonomy('genre', 'books', [
'label' => 'Genre',
'rewrite' => ['slug' => 'genre'],
'hierarchical' => true,
]);
}
add_action('init', 'create_book_taxonomy');

4. What are WordPress hooks?

Hooks allow customization of WordPress without modifying core files.

  • Actions (do_action) allow adding functionality.

  • Filters (apply_filters) modify existing data.

5. What is the difference between an action hook and a filter hook?

Feature Action Hook Filter Hook
Purpose Executes functions Modifies data
Example wp_footer the_content

Example:

// Action Hook
add_action('wp_footer', 'custom_footer');
function custom_footer() {
echo '<p>Custom Footer Content</p>';
}

// Filter Hook
add_filter('the_content', 'modify_content');
function modify_content($content) {
return $content . '<p>Extra text added!</p>';
}

Advanced WordPress Questions

6. How does WordPress handle user roles and capabilities?

WordPress has 6 default roles:

  • Administrator – Full control

  • Editor – Manages posts, pages

  • Author – Creates and publishes posts

  • Contributor – Can write but not publish

  • Subscriber – Can comment

  • Super Admin – For multisite

7. How do you secure a WordPress website?

  • Use strong passwords

  • Limit login attempts

  • Install security plugins (Wordfence, Sucuri)

  • Use HTTPS

  • Keep themes and plugins updated

8. What are the different ways to improve WordPress performance?

  • Use caching (WP Rocket, W3 Total Cache)

  • Optimize images (Smush, TinyPNG)

  • Use a CDN (Cloudflare)

  • Minify CSS/JS

  • Optimize database

9. How can you prevent SQL injection attacks in WordPress?

  • Use prepare() for database queries:

global $wpdb;
$wpdb->prepare("SELECT * FROM wp_users WHERE user_email = %s", $email);

10. What is WP-CLI? How can it be used?

WP-CLI is a command-line tool for WordPress management. Example commands:

wp plugin install woocommerce --activate
wp user list
wp db export backup.sql

Leave a Reply

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