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
:
3. How do you create a custom taxonomy in WordPress?
Using register_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:
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:
10. What is WP-CLI? How can it be used?
WP-CLI is a command-line tool for WordPress management. Example commands: