Wordpress Fundamentals
Wordpress Fundamentals
Understand WordPress architecture, core files, and directory structure
Install and configure WordPress locally and on production servers
Master WordPress database structure and content management
Learn the WordPress Loop, template hierarchy, and core functions
Configure wp-config.php for development and production environments
Implement WordPress best practices, security, and performance optimization
WordPress is the world's most popular content management system (CMS), powering over 43% of all
websites on the internet. Originally launched in 2003 as a blogging platform, WordPress has evolved
into a powerful, flexible system for building any type of website.
Open Source:
Free to use, modify, and distribute (GPL license)
PHP-Based:
Built with PHP and MySQL/MariaDB
Extensible:
60,000+ plugins and 10,000+ themes available
User-Friendly:
Intuitive admin interface for non-developers
SEO-Friendly:
Built-in features and plugins for search optimization
Community-Driven:
Massive global community and resources
Powers small blogs to enterprise-level sites
WordPress.org (Self-Hosted)
WordPress.com (Hosted)
This course focuses on WordPress.org (self-hosted) for full development capabilities.
Learn about WordPress Architecture.
⚠️ Important Rules:
modify core files in wp-admin/ or wp-includes/
1wordpress/
2├── wp-admin/ # Admin dashboard files (DO NOT MODIFY)
3│ ├── admin.php
4│ ├── admin-ajax.php
5│ ├── index.php
6│ └── ...
7├── wp-content/ # Your customizable content
8│ ├── plugins/ # Custom and third-party plugins
9│ │ ├── akismet/
10│ │ ├── my-custom-plugin/
11│ │ └── ...
12│ ├── themes/ # Your themes
13│ │ ├── twentytwentyfour/
14│ │ ├── my-theme/
15│ │ └── ...
16│ ├── uploads/ # Media library files
17│ │ ├── 2024/
18│ │ │ ├── 01/
19│ │ │ └── ...
20│ │ └── ...
21│ ├── languages/ # Translation files
22│ └── mu-plugins/ # Must-use plugins (auto-activated)
23├── wp-includes/ # Core WordPress libraries (DO NOT MODIFY)
24│ ├── class-wp-query.php
25│ ├── functions.php
26│ ├── post.php
27│ └── ...
28├── index.php # Main entry point
29├── wp-config.php # Configuration file (YOU CUSTOMIZE THIS)
30├── wp-config-sample.php # Sample configuration
31├── wp-load.php # Bootstrap loader
32├── wp-settings.php # Core initialization
33├── .htaccess # Apache rewrite rules (auto-generated)
34└── xmlrpc.php # XML-RPC interfaceWordPress uses MySQL/MariaDB with 12 default tables (prefix: wp_):
1wp_posts # Posts, pages, custom post types, revisions
2├── ID (bigint)
3├── post_author (bigint)
4├── post_date (datetime)
5├── post_content (longtext)
6├── post_title (text)
7├── post_status (varchar) # publish, draft, pending, private
8├── post_type (varchar) # post, page, attachment, custom
9└── ...
10
11wp_postmeta # Custom fields/meta data for posts
12├── meta_id (bigint)
13├── post_id (bigint)
14├── meta_key (varchar)
15└── meta_value (longtext)
16
17wp_users # User accounts
18├── ID (bigint)
19├── user_login (varchar)
20├── user_pass (varchar) # Hashed password
21├── user_email (varchar)
22├── user_registered (datetime)
23└── ...
24
25wp_usermeta # User metadata (preferences, capabilities)
26├── umeta_id (bigint)
27├── user_id (bigint)
28├── meta_key (varchar)
29└── meta_value (longtext)
30
31wp_comments # Comments and trackbacks
32├── comment_ID (bigint)
33├── comment_post_ID (bigint)
34├── comment_author (tinytext)
35├── comment_content (text)
36├── comment_approved (varchar)
37└── ...
38
39wp_commentmeta # Comment metadata
40
41wp_terms # Categories, tags, custom taxonomies
42├── term_id (bigint)
43├── name (varchar)
44├── slug (varchar)
45└── term_group (bigint)
46
47wp_term_taxonomy # Taxonomy definitions
48├── term_taxonomy_id (bigint)
49├── term_id (bigint)
50├── taxonomy (varchar) # category, post_tag, custom
51├── description (longtext)
52├── parent (bigint)
53└── count (bigint)
54
55wp_term_relationships # Post-to-term assignments
56├── object_id (bigint) # post_id
57├── term_taxonomy_id (bigint)
58└── term_order (int)
59
60wp_options # Site settings and configuration
61├── option_id (bigint)
62├── option_name (varchar) # siteurl, blogname, etc.
63├── option_value (longtext)
64└── autoload (varchar) # yes/no
65
66wp_links # Blogroll links (legacy)
67
68wp_termmeta # Term metadataLearn about WordPress Request Lifecycle.
11. User Request → index.php
2 ↓
32. Load wp-config.php (database credentials, constants)
4 ↓
53. Load wp-settings.php (initialize WordPress)
6 ├── Load core libraries (wp-includes/)
7 ├── Connect to database
8 ├── Load active plugins
9 ├── Load active theme
10 └── Set up hooks and filters
11 ↓
124. Parse Request (WP::parse_request())
13 ├── Check .htaccess rewrite rules
14 ├── Determine query variables
15 └── Route to appropriate handler
16 ↓
175. Query Posts (WP_Query)
18 ├── Build SQL query based on request
19 ├── Execute database query
20 └── Load post objects
21 ↓
226. Load Template (template-loader.php)
23 ├── Check template hierarchy
24 ├── Find appropriate template file
25 └── Include template from active theme
26 ↓
277. Render Output (The Loop)
28 ├── Process template PHP code
29 ├── Execute shortcodes
30 ├── Apply content filters
31 └── Output HTML
32 ↓
338. Send Response → User BrowserLearn about Installing WordPress.
Option A: Local by Flywheel
Option B: Manual Installation (XAMPP/MAMP)
Option C: Docker Compose
1# Download Local by Flywheel
2# Visit: https://localwp.com/
3
4Steps:
51. Download and install Local for your OS (Windows/Mac/Linux)
62. Click "Create a new site"
73. Enter site name (e.g., "my-wordpress-site")
84. Choose environment:
9 - PHP: 8.1 or higher
10 - Web Server: Nginx (recommended) or Apache
11 - Database: MySQL 8.0
125. Set up WordPress:
13 - Username: admin
14 - Password: (strong password)
15 - Email: your-email@example.com
166. Click "Add Site"
177. Access site at: http://my-wordpress-site.local
18
19✓ Benefits:
20 • One-click WordPress installation
21 • Easy multi-site management
22 • Built-in SSL certificates
23 • Live link sharing
24 • Blueprint templates1# Step 1: Install XAMPP
2# Download from: https://www.apachefriends.org/
3
4# Step 2: Start Apache and MySQL
5# Open XAMPP Control Panel
6# Click "Start" for Apache and MySQL modules
7
8# Step 3: Create Database
9# Visit: http://localhost/phpmyadmin
10# Click "New" → Enter database name: "wordpress_db"
11# Click "Create"
12
13# Step 4: Download WordPress
14# Visit: https://wordpress.org/download/
15# Download latest version (e.g., wordpress-6.4.2.zip)
16
17# Step 5: Extract to XAMPP
18# Extract ZIP to: C:/xampp/htdocs/my-wordpress-site/
19# (or /Applications/XAMPP/htdocs/my-wordpress-site/ on Mac)
20
21# Step 6: Install WordPress
22# Visit: http://localhost/my-wordpress-site
23# Follow 5-minute installation wizard:
24 1. Select language
25 2. Enter database details:
26 - Database Name: wordpress_db
27 - Username: root
28 - Password: (leave blank for XAMPP default)
29 - Database Host: localhost
30 - Table Prefix: wp_
31 3. Submit
32 4. Enter site information:
33 - Site Title
34 - Username (avoid 'admin')
35 - Password (strong)
36 - Email
37 5. Install WordPress
38 6. Login at: http://localhost/my-wordpress-site/wp-admin1# Create docker-compose.yml
2version: '3.8'
3
4services:
5 wordpress:
6 image: wordpress:latest
7 container_name: my_wordpress
8 ports:
9 - "8080:80"
10 environment:
11 WORDPRESS_DB_HOST: db:3306
12 WORDPRESS_DB_USER: wordpress
13 WORDPRESS_DB_PASSWORD: wordpress_pass
14 WORDPRESS_DB_NAME: wordpress_db
15 volumes:
16 - ./wordpress:/var/www/html
17 depends_on:
18 - db
19
20 db:
21 image: mysql:8.0
22 container_name: my_wordpress_db
23 environment:
24 MYSQL_ROOT_PASSWORD: root_pass
25 MYSQL_DATABASE: wordpress_db
26 MYSQL_USER: wordpress
27 MYSQL_PASSWORD: wordpress_pass
28 volumes:
29 - db_data:/var/lib/mysql
30
31 phpmyadmin:
32 image: phpmyadmin:latest
33 container_name: my_phpmyadmin
34 ports:
35 - "8081:80"
36 environment:
37 PMA_HOST: db
38 PMA_USER: wordpress
39 PMA_PASSWORD: wordpress_pass
40 depends_on:
41 - db
42
43volumes:
44 db_data:
45
46# Run:
47docker-compose up -d
48
49# Access:
50# WordPress: http://localhost:8080
51# phpMyAdmin: http://localhost:8081
52
53# Stop:
54docker-compose downLearn about Method 2: Production Server.
1# Prerequisites:
2# - VPS/Shared hosting with SSH access
3# - LAMP/LEMP stack installed
4# - Domain name pointed to server
5
6# Step 1: Create Database
7mysql -u root -p
8CREATE DATABASE wordpress_prod CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
9CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'strong_password_here';
10GRANT ALL PRIVILEGES ON wordpress_prod.* TO 'wpuser'@'localhost';
11FLUSH PRIVILEGES;
12EXIT;
13
14# Step 2: Download WordPress
15cd /var/www/html
16sudo wget https://wordpress.org/latest.tar.gz
17sudo tar -xzvf latest.tar.gz
18sudo mv wordpress/* .
19sudo rm -rf wordpress latest.tar.gz
20
21# Step 3: Set Permissions
22sudo chown -R www-data:www-data /var/www/html
23sudo find /var/www/html -type d -exec chmod 755 {} \\;
24sudo find /var/www/html -type f -exec chmod 644 {} \\;
25
26# Step 4: Configure WordPress
27sudo cp wp-config-sample.php wp-config.php
28sudo nano wp-config.php
29
30# Edit database credentials:
31define('DB_NAME', 'wordpress_prod');
32define('DB_USER', 'wpuser');
33define('DB_PASSWORD', 'strong_password_here');
34define('DB_HOST', 'localhost');
35
36# Step 5: Generate Security Keys
37# Visit: https://api.wordpress.org/secret-key/1.1/salt/
38# Copy and paste keys into wp-config.php
39
40# Step 6: Configure Nginx (if using Nginx)
41sudo nano /etc/nginx/sites-available/wordpress
42
43server {
44 listen 80;
45 server_name yourdomain.com www.yourdomain.com;
46 root /var/www/html;
47 index index.php;
48
49 location / {
50 try_files $uri $uri/ /index.php?$args;
51 }
52
53 location ~ \\.php$ {
54 include snippets/fastcgi-php.conf;
55 fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
56 }
57
58 location ~ /\\.ht {
59 deny all;
60 }
61}
62
63sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
64sudo nginx -t
65sudo systemctl reload nginx
66
67# Step 7: Complete Installation
68# Visit: http://yourdomain.com
69# Follow installation wizard
70
71# Step 8: Secure with SSL
72sudo apt install certbot python3-certbot-nginx
73sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
74sudo certbot renew --dry-run # Test auto-renewalLearn about wp-config.php Configuration.
Learn about Essential Configuration.
1<?php
2/**
3 * WordPress Configuration File
4 */
5
6// ** Database Settings ** //
7define('DB_NAME', 'database_name_here');
8define('DB_USER', 'username_here');
9define('DB_PASSWORD', 'password_here');
10define('DB_HOST', 'localhost'); // Usually 'localhost', sometimes IP or socket
11define('DB_CHARSET', 'utf8mb4');
12define('DB_COLLATE', '');
13
14// ** Authentication Unique Keys and Salts ** //
15// Generate at: https://api.wordpress.org/secret-key/1.1/salt/
16define('AUTH_KEY', 'put your unique phrase here');
17define('SECURE_AUTH_KEY', 'put your unique phrase here');
18define('LOGGED_IN_KEY', 'put your unique phrase here');
19define('NONCE_KEY', 'put your unique phrase here');
20define('AUTH_SALT', 'put your unique phrase here');
21define('SECURE_AUTH_SALT', 'put your unique phrase here');
22define('LOGGED_IN_SALT', 'put your unique phrase here');
23define('NONCE_SALT', 'put your unique phrase here');
24
25// ** WordPress Database Table Prefix ** //
26$table_prefix = 'wp_'; // Change for security (e.g., 'mysite_')
27
28// ** Debugging ** //
29define('WP_DEBUG', false); // Set to true in development
30define('WP_DEBUG_LOG', false); // Log to wp-content/debug.log
31define('WP_DEBUG_DISPLAY', false); // Display errors on screen
32define('SCRIPT_DEBUG', false); // Use unminified JS/CSS
33
34// ** Performance ** //
35define('WP_CACHE', true); // Enable caching
36define('COMPRESS_CSS', true);
37define('COMPRESS_SCRIPTS', true);
38define('CONCATENATE_SCRIPTS', true);
39define('ENFORCE_GZIP', true);
40
41// ** Security ** //
42define('DISALLOW_FILE_EDIT', true); // Disable theme/plugin editor
43define('DISALLOW_FILE_MODS', true); // Disable all file modifications
44define('FORCE_SSL_ADMIN', true); // Force SSL for admin
45define('WP_AUTO_UPDATE_CORE', 'minor'); // Auto-update: true, false, 'minor'
46
47// ** File System ** //
48define('FS_METHOD', 'direct'); // File system method: direct, ssh2, ftpext, ftpsockets
49define('FS_CHMOD_DIR', (0755 & ~umask()));
50define('FS_CHMOD_FILE', (0644 & ~umask()));
51
52// ** Memory Limits ** //
53define('WP_MEMORY_LIMIT', '256M'); // Standard limit
54define('WP_MAX_MEMORY_LIMIT', '512M'); // Admin area limit
55
56// ** Revisions ** //
57define('WP_POST_REVISIONS', 5); // Limit revisions (false to disable)
58define('AUTOSAVE_INTERVAL', 160); // Autosave interval in seconds
59
60// ** Trash ** //
61define('EMPTY_TRASH_DAYS', 30); // Days before permanent deletion
62
63// ** Multisite (if enabled) ** //
64// define('WP_ALLOW_MULTISITE', true);
65// define('MULTISITE', true);
66// define('SUBDOMAIN_INSTALL', false);
67// define('DOMAIN_CURRENT_SITE', 'example.com');
68// define('PATH_CURRENT_SITE', '/');
69// define('SITE_ID_CURRENT_SITE', 1);
70// define('BLOG_ID_CURRENT_SITE', 1);
71
72// ** Custom Content Directory (optional) ** //
73// define('WP_CONTENT_DIR', dirname(__FILE__) . '/content');
74// define('WP_CONTENT_URL', 'http://example.com/content');
75
76// ** Custom Plugin Directory (optional) ** //
77// define('WP_PLUGIN_DIR', dirname(__FILE__) . '/content/plugins');
78// define('WP_PLUGIN_URL', 'http://example.com/content/plugins');
79
80/* That's all, stop editing! Happy publishing. */
81
82/** Absolute path to the WordPress directory. */
83if (!defined('ABSPATH')) {
84 define('ABSPATH', __DIR__ . '/');
85}
86
87/** Sets up WordPress vars and included files. */
88require_once ABSPATH . 'wp-settings.php';Learn about Environment-Specific Configuration.
1<?php
2/**
3 * Environment-Specific Configuration
4 * Detect environment and load appropriate settings
5 */
6
7// Detect environment
8$hostname = gethostname();
9
10if (strpos($hostname, 'local') !== false || $_SERVER['HTTP_HOST'] === 'localhost') {
11 // Local Development Environment
12 define('WP_ENV', 'development');
13 define('DB_NAME', 'local_wordpress');
14 define('DB_USER', 'root');
15 define('DB_PASSWORD', 'root');
16 define('DB_HOST', 'localhost');
17
18 define('WP_DEBUG', true);
19 define('WP_DEBUG_LOG', true);
20 define('WP_DEBUG_DISPLAY', true);
21 define('SCRIPT_DEBUG', true);
22 define('SAVEQUERIES', true); // Log database queries
23
24 define('DISALLOW_FILE_EDIT', false);
25 define('DISALLOW_FILE_MODS', false);
26
27} elseif (strpos($_SERVER['HTTP_HOST'], 'staging') !== false) {
28 // Staging Environment
29 define('WP_ENV', 'staging');
30 define('DB_NAME', 'staging_wordpress');
31 define('DB_USER', 'staging_user');
32 define('DB_PASSWORD', 'staging_password');
33 define('DB_HOST', 'localhost');
34
35 define('WP_DEBUG', true);
36 define('WP_DEBUG_LOG', true);
37 define('WP_DEBUG_DISPLAY', false);
38
39 define('DISALLOW_FILE_EDIT', true);
40 define('DISALLOW_FILE_MODS', false);
41
42} else {
43 // Production Environment
44 define('WP_ENV', 'production');
45 define('DB_NAME', 'prod_wordpress');
46 define('DB_USER', 'prod_user');
47 define('DB_PASSWORD', 'secure_prod_password');
48 define('DB_HOST', 'localhost');
49
50 define('WP_DEBUG', false);
51 define('WP_DEBUG_LOG', false);
52 define('WP_DEBUG_DISPLAY', false);
53
54 define('DISALLOW_FILE_EDIT', true);
55 define('DISALLOW_FILE_MODS', true);
56 define('FORCE_SSL_ADMIN', true);
57
58 define('WP_CACHE', true);
59 define('COMPRESS_CSS', true);
60 define('COMPRESS_SCRIPTS', true);
61}
62
63// Security keys (same for all environments - use unique values)
64define('AUTH_KEY', 'put your unique phrase here');
65define('SECURE_AUTH_KEY', 'put your unique phrase here');
66// ... rest of security keys
67
68$table_prefix = 'wp_';
69
70if (!defined('ABSPATH')) {
71 define('ABSPATH', __DIR__ . '/');
72}
73
74require_once ABSPATH . 'wp-settings.php';The Loop is the most fundamental concept in WordPress. It's PHP code that displays posts/pages
by cycling through query results. The Loop runs in every WordPress page to output content.
Learn about Basic Loop Structure.
1<?php
2// Check if there are posts to display
3if (have_posts()) :
4
5 // Start the loop
6 while (have_posts()) : the_post();
7
8 // Display post content
9 ?>
10 <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
11 <h2><?php the_title(); ?></h2>
12 <div class="meta">
13 Posted on <?php the_date(); ?>
14 by <?php the_author(); ?>
15 </div>
16 <div class="content">
17 <?php the_content(); ?>
18 </div>
19 <div class="tags">
20 <?php the_tags('Tags: ', ', '); ?>
21 </div>
22 </article>
23 <?php
24
25 endwhile; // End of the loop
26
27 // Pagination
28 the_posts_pagination();
29
30else :
31
32 // No posts found
33 echo '<p>No posts found.</p>';
34
35endif;
36?>Loop Control Functions
Content Display Functions
Get Functions (Return Values)
1have_posts() // Returns true if there are posts to display
2the_post() // Sets up the current post data (must be called in loop)
3rewind_posts() // Resets the loop to the beginning1the_ID() // Display post ID
2the_title() // Display post title
3the_content() // Display full post content
4the_excerpt() // Display post excerpt
5the_permalink() // Display post URL
6the_author() // Display author name
7the_date() // Display post date
8the_time() // Display post time
9the_category() // Display post categories
10the_tags() // Display post tags
11post_class() // Add CSS classes to post container
12body_class() // Add CSS classes to body tag1get_the_ID() // Return post ID
2get_the_title() // Return post title
3get_the_content() // Return post content
4get_the_excerpt() // Return post excerpt
5get_permalink() // Return post URL
6get_the_author() // Return author name
7get_the_date() // Return post date
8get_the_category() // Return post categories array
9get_the_tags() // Return post tags array
10get_post_thumbnail_id() // Return featured image ID
11get_the_post_thumbnail() // Return featured image HTMLLearn about Custom Query with WP_Query.
1<?php
2// Create custom query
3$args = array(
4 'post_type' => 'post',
5 'posts_per_page' => 10,
6 'category_name' => 'news',
7 'orderby' => 'date',
8 'order' => 'DESC',
9 'post_status' => 'publish',
10);
11
12$custom_query = new WP_Query($args);
13
14// Custom loop
15if ($custom_query->have_posts()) :
16 while ($custom_query->have_posts()) : $custom_query->the_post();
17 ?>
18 <article>
19 <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
20 <?php the_excerpt(); ?>
21 </article>
22 <?php
23 endwhile;
24
25 // Restore original post data
26 wp_reset_postdata();
27else :
28 echo '<p>No posts found.</p>';
29endif;
30?>
31
32<?php
33// Complex WP_Query example
34$args = array(
35 'post_type' => array('post', 'page'),
36 'posts_per_page' => 5,
37 'meta_query' => array(
38 array(
39 'key' => 'featured',
40 'value' => '1',
41 'compare' => '='
42 )
43 ),
44 'tax_query' => array(
45 array(
46 'taxonomy' => 'category',
47 'field' => 'slug',
48 'terms' => 'featured'
49 )
50 ),
51 'date_query' => array(
52 array(
53 'after' => '1 month ago',
54 'before' => 'today'
55 )
56 ),
57);
58
59$query = new WP_Query($args);
60?>WordPress uses a template hierarchy to determine which template file to use for displaying content.
It looks for templates in order of specificity, falling back to more generic templates.
Learn about Template Hierarchy Flow.
1Homepage:
21. front-page.php
32. home.php
43. index.php
5
6Single Post:
71. single-{post-type}-{slug}.php (e.g., single-post-hello-world.php)
82. single-{post-type}.php (e.g., single-post.php)
93. single.php
104. singular.php
115. index.php
12
13Page:
141. page-{slug}.php (e.g., page-about.php)
152. page-{id}.php (e.g., page-42.php)
163. page-{template}.php (custom page template)
174. page.php
185. singular.php
196. index.php
20
21Category Archive:
221. category-{slug}.php (e.g., category-news.php)
232. category-{id}.php (e.g., category-5.php)
243. category.php
254. archive.php
265. index.php
27
28Tag Archive:
291. tag-{slug}.php (e.g., tag-wordpress.php)
302. tag-{id}.php
313. tag.php
324. archive.php
335. index.php
34
35Custom Post Type Archive:
361. archive-{post-type}.php (e.g., archive-product.php)
372. archive.php
383. index.php
39
40Author Archive:
411. author-{nicename}.php (e.g., author-john.php)
422. author-{id}.php
433. author.php
444. archive.php
455. index.php
46
47Date Archive:
481. date.php
492. archive.php
503. index.php
51
52Search Results:
531. search.php
542. index.php
55
56404 Error:
571. 404.php
582. index.php
59
60Attachment (Media):
611. {mime-type}.php (e.g., image.php, video.php)
622. attachment.php
633. single-attachment-{slug}.php
644. single-attachment.php
655. single.php
666. singular.php
677. index.phpLearn about Template Parts.
1<?php
2// Include template parts
3get_header(); // Includes header.php
4get_footer(); // Includes footer.php
5get_sidebar(); // Includes sidebar.php
6
7// Include custom template parts
8get_template_part('template-parts/content', 'post');
9// Looks for: template-parts/content-post.php, then content.php
10
11get_template_part('template-parts/navigation', 'mobile');
12// Looks for: template-parts/navigation-mobile.php, then navigation.php
13
14// With custom loader
15locate_template(array('custom-header.php', 'header.php'), true, false);
16?>
17
18<!-- Example: template-parts/content-post.php -->
19<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
20 <header class="entry-header">
21 <?php the_title('<h2 class="entry-title">', '</h2>'); ?>
22 <div class="entry-meta">
23 Posted on <?php the_date(); ?> by <?php the_author(); ?>
24 </div>
25 </header>
26
27 <?php if (has_post_thumbnail()) : ?>
28 <div class="post-thumbnail">
29 <?php the_post_thumbnail('large'); ?>
30 </div>
31 <?php endif; ?>
32
33 <div class="entry-content">
34 <?php the_content(); ?>
35 </div>
36
37 <footer class="entry-footer">
38 <?php the_tags('<span class="tags">Tags: ', ', ', '</span>'); ?>
39 <?php the_category(', '); ?>
40 </footer>
41</article>Learn about Hands-On Exercises.
Set up a local WordPress development environment and explore the admin dashboard.
Requirements:
Install WordPress using Local by Flywheel or XAMPP
Configure wp-config.php for development mode (WP_DEBUG enabled)
Create 5 sample posts and 3 sample pages
Upload at least 3 images to the media library
Create 2 categories and assign posts to them
Add 3 tags to your posts
View Solution
Step-by-Step Solution: 1. Install Local by Flywheel: - Download from https://localwp.com/ - Install for your operating system - Open Local 2. Create New Site: - Click "+ Create a new site" - Site name: "my-first-wordpress" - Environment: PHP 8.1, Nginx, MySQL 8.0 - WordPress username: admin - Password: StrongPassword123! - Email: [email protected] - Click "Add Site" 3. Enable Debug Mode: - Right-click site → "Open Site Shell" - Navigate to site folder - Open wp-config.php - Find: define('WP_DEBUG', false); - Change to: define('WP_DEBUG', true); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY', true); define('SCRIPT_DEBUG', true); - Save file 4. Create Sample Content: a) Create Posts: - Dashboard → Posts → Add New - Title: "My First Blog Post" - Content: Add lorem ipsum text - Featured Image: Upload image - Category: Create "News" - Tags: Add "wordpress", "tutorial" - Click "Publish" - Repeat 4 more times with different titles b) Create Pages: - Dashboard → Pages → Add New - Create: About, Contact, Services pages - Add content to each - Click "Publish" c) Create Categories: - Dashboard → Posts → Categories - Name: "News", Slug: "news" - Name: "Tutorials", Slug: "tutorials" - Click "Add New Category" d) Create Tags: - Dashboard → Posts → Tags - Add: "wordpress", "php", "development" 5. Verify Installation: - Visit frontend: http://my-first-wordpress.local - Visit admin: http://my-first-wordpress.local/wp-admin - Check debug.log: wp-content/debug.log ✓ Exercise Complete!
Build custom page templates using the WordPress Loop and template hierarchy.
Requirements:
Create a custom homepage template (front-page.php)
Create a custom archive template showing latest 10 posts
Create a custom single post template with author bio
Add custom WP_Query to show related posts by category
Implement pagination on archive pages
View Solution
Solution provided in the interactive code editor. Navigate to the editor tab to see full implementation of: 1. front-page.php - Custom homepage 2. archive.php - Custom archive with pagination 3. single.php - Custom single post with related posts 4. Author bio section 5. WP_Query for related posts Key concepts demonstrated: - WordPress Loop - WP_Query custom queries - Template hierarchy - Pagination functions - Conditional tags (is_home(), is_archive(), etc.) - Author metadata display - Related posts algorithm
Deploy WordPress to a production server with security hardening and performance optimization.
Requirements:
Set up LEMP stack on Ubuntu server
Install WordPress with proper file permissions
Configure wp-config.php for production (debug off, security keys)
Implement SSL with Let's Encrypt
Set up automatic backups to S3 or external storage
Configure caching (object cache with Redis, page cache)
Implement security hardening (disable file editing, limit login attempts)
View Solution
Complete deployment commands provided in editor. Deployment checklist: 1. ✓ Server setup (Nginx, PHP-FPM, MySQL) 2. ✓ WordPress installation 3. ✓ File permissions (755 dirs, 644 files) 4. ✓ wp-config.php production settings 5. ✓ SSL certificate (Let's Encrypt) 6. ✓ Redis object caching 7. ✓ Security headers (Nginx) 8. ✓ Disable XML-RPC 9. ✓ Automated backups 10. ✓ Monitoring setup Security measures: - File editing disabled - Strong database passwords - Security keys rotated - Login attempt limiting - Firewall configured - Regular updates scheduled Performance optimizations: - Redis object cache - PHP OPcache enabled - Gzip compression - Browser caching headers - CDN ready configuration
A) It contains WordPress core files that should never be modified
B) It stores all user-generated content including themes, plugins, and uploads
C) It contains database connection settings
D) It's only used for caching temporary files
Show Answer
The wp-content directory is where ALL user-customizable content lives. This includes themes (wp-content/themes/),
plugins (wp-content/plugins/), uploaded media files (wp-content/uploads/), translation files (wp-content/languages/),
and must-use plugins (wp-content/mu-plugins/). This is the only directory you should customize - never modify
wp-admin or wp-includes as those contain WordPress core files that get overwritten during updates.
A) They do exactly the same thing
B) the_content() displays content directly; get_the_content() returns it as a variable
C) the_content() is faster than get_the_content()
D) get_the_content() can only be used outside The Loop
Show Answer
This is a fundamental distinction in WordPress template functions. Functions prefixed with "the_" (like the_title(),
the_content(), the_permalink()) immediately echo/display their output. Functions prefixed with "get_the_" (like
get_the_title(), get_the_content(), get_permalink()) return the value so you can store it in a variable or
manipulate it before displaying. Use "the_" when you want immediate output, "get_the_" when you need to process
or conditionally display the value.
A) It improves WordPress performance significantly
B) It prevents attackers from editing theme/plugin files through the admin if they gain access
C) It's required for WordPress to function properly
D) It enables automatic WordPress updates
Show Answer
DISALLOW_FILE_EDIT is a critical security setting that removes the theme and plugin file editors from the WordPress
admin dashboard. If an attacker compromises an admin account, they could use these editors to inject malicious PHP
code directly into your theme or plugin files, giving them complete server access. By disabling this feature, you
force all file modifications to go through proper deployment processes (FTP/SSH) which are typically better secured
and logged. This is essential for production environments.
A) It deletes all posts from the database
B) It restores global post data after a custom WP_Query loop
C) It clears the WordPress cache
D) It resets user passwords
Show Answer
When you create a custom WP_Query, it modifies global post variables ($post, $wp_query). After your custom loop
completes, you MUST call wp_reset_postdata() to restore the original query and post data. Without this, subsequent
template tags like the_title() or the_content() might display data from your custom query instead of the main query,
causing confusing bugs. Always use it immediately after endwhile in custom WP_Query loops. Example: while ($query->have_posts()) :
$query->the_post(); /* content */ endwhile; wp_reset_postdata();
A) A ranking of which themes are better than others
B) The order WordPress checks for template files, from specific to generic
C) A list of required files every theme must have
D) The admin user permission levels
Show Answer
The template hierarchy is WordPress's system for determining which PHP file to use when displaying different types
of content. It checks for templates in order from most specific to most generic. For example, when displaying a
single post, it looks for: single-
.php → single-
.php → single.php → singular.php →
index.php. This allows you to create highly customized templates for specific content while falling back to generic
templates when needed. Understanding this hierarchy is essential for theme development because it lets you override
specific templates without modifying others.
Learn about WordPress Best Practices.
Learn about Development.
Learn about Security.
Learn about Performance.
Learn about Database.
Learn about File Management.
Learn about Content Management.
Learn about SEO.
Learn about Maintenance.
Learn about Additional Resources.
WordPress Documentation
Complete official documentation
WordPress Developer Resources
Code reference and developer guides
WordPress Code Reference
Complete function and hook reference
WordPress Codex
Legacy documentation (still useful)
Template Hierarchy
Visual template hierarchy guide
WordPress Learn
Free official WordPress courses
WPMU DEV Blog
WordPress tutorials and guides
Smashing Magazine - WordPress
Advanced WordPress articles
WordPress news and updates
WordPress.tv
WordCamp presentations and tutorials
Local by Flywheel
Best local development environment
Query Monitor
Developer debugging plugin
Debugging toolbar
GenerateWP
WordPress code generator
Command-line interface for WordPress
WordPress Support Forums
Official community support
WordPress Slack
Real-time WordPress community chat
Stack Overflow - WordPress
Programming Q&A
r/WordPress
WordPress subreddit
WordCamp Central
Find WordPress conferences near you
Your progress is saved in this browser, on this device only.