Contents
WordPress
The most widespread content management system: themes, plugins, hooks, custom post types and the REST API.
1.Getting started
- Meet WordPressWhat WordPress is, how to install it, what a site consists of, where themes and plugins live and how to turn on debug mode.
- Your own themeCreating a WordPress theme from scratch: the style.css and index.php files, the theme header, functions.php and enabling features with add_theme_support.
- The LoopThe main WordPress loop: have_posts and the_post, functions for the title, content, date and image, the difference between the_ and get_, and pagination.
- The template hierarchyHow WordPress picks a template file: single.php, page.php, archive.php, 404.php, templates for individual pages and conditional tags.
- Header, footer and template partsThe shared parts of a WordPress theme: header.php and footer.php, get_template_part with arguments, menus and widget areas.
2.Development
- Hooks: actions and filtersWordPress hooks: add_action and add_filter, priority and the number of arguments, removing other handlers and your own hooks.
- Your own pluginCreating a WordPress plugin: a file with a header, guarding against direct access, activation and uninstall hooks, file paths and unique names.
- Styles and scriptsAdding CSS and JavaScript in WordPress: wp_enqueue_style and wp_enqueue_script, dependencies, versions, passing data to a script and conditional loading.
- Custom post types and taxonomiesCustom post types in WordPress: register_post_type, its settings and supported fields, custom taxonomies and templates for the new type.
- Custom fieldsWordPress post meta: get_post_meta and update_post_meta, your own field in the editor with add_meta_box, saving safely and the ACF plugin.
- Custom queries: WP_QueryThe WP_Query class: selecting posts by type, category, taxonomy and custom fields, a second loop on a page and changing the main query.
- Shortcodes and blocksInserts in WordPress post content: shortcodes with attributes and content, Gutenberg editor blocks, dynamic blocks and block patterns.
3.Application
- Options and dashboard pagesWordPress options: the get_option and update_option functions, your own page in the dashboard, the Settings API with value sanitising.
- The database and $wpdbThe WordPress database: the main tables, the $wpdb object, prepared queries, inserting and updating rows, a custom table with dbDelta.
- SecuritySecure code for WordPress: escaping output, sanitising input, nonces, capability checks and protecting files.
- The REST APIThe WordPress REST API: the built-in wp-json addresses, your own route with register_rest_route, parameters, permissions and requests from JavaScript.
- AJAX requestsAJAX in WordPress: the wp_ajax and wp_ajax_nopriv handlers, the admin-ajax.php file, checking the nonce, the wp_send_json response and a request from JavaScript.
- Users, roles and capabilitiesWordPress users: the built-in roles, checking rights with current_user_can, the current user, custom roles and capabilities, user data.
4.Growing the project
- Child themesA WordPress child theme: how to change someone else's theme without losing the edits on update, overriding templates and your own functions.php.
- Translating a theme or pluginTranslation in WordPress: the __ and _e functions, the text domain, placeholders, plurals, and the .pot, .po and .mo files.
- Caching and scheduled tasksSpeed and background jobs in WordPress: transients for temporary caching, the object cache, WP-Cron schedules and the server's real cron.
- WP-CLI and deploymentManaging WordPress from the terminal with WP-CLI, moving a site to a server, replacing addresses in the database and production settings.